[Koha-bugs] [Bug 13995] Proper Exception handling

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Thu Jul 16 14:16:49 CEST 2015


http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=13995

Olli-Antti Kivilahti <olli-antti.kivilahti at jns.fi> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #40717|0                           |1
        is obsolete|                            |

--- Comment #10 from Olli-Antti Kivilahti <olli-antti.kivilahti at jns.fi> ---
Created attachment 41018
  -->
http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=41018&action=edit
Bug 13995 - Proper Exception handling

Koha has issues with propagating errors and exceptions from the business layer
to the front-end. Using a more sophisticated system of named Exceptions we can
send more formal signals towards the user.
Catching different types of Exceptions makes for a more concise handling of
errors.
Also throwing/catching Exceptions is a industry standard and for a good reason.
There is no point for Koha to lurk behind.

USAGE:
try {
    Koha::Exception::BadSystemPreference->throw(error => 'Syspref
DisplayIconsXSLT is not a valid boolean');
} catch {
    if (blessed($_) && $_->isa('Koha::Exception::BadSystemPreference')) {
        print $_->as_string();
        warn $_->error, "\n", $_->trace->as_string, "\n";
    }
    else {
        $_->rethrow();
    }
}

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list