[Koha-bugs] [Bug 25032] Generic unhandled exception handling

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Tue Mar 31 23:51:51 CEST 2020


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25032

--- Comment #2 from Tomás Cohen Arazi <tomascohen at gmail.com> ---
Created attachment 102161
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=102161&action=edit
Bug 25032: Generic unhandled exception handling on API [WIP]

This patch adds Koha::Logger as the default logger for the API, and
introduces a new helper plugin that takes care of handling the unhandled
exceptions. Basically, with this we would write something like this in
our controller methods:

    try {
        ...
    }
    catch {
        if ( know_exception ) {
            handle_known_exception($_);
        }

        $c->unhandled_exception($_);
    }

Without this, we end up adding more and more handling 'just in case'.

This is WIP, to test:
1. Edit the Koha/REST/V1/Cities.pm 'list' method adding
   die("Nada"); before the render step.
2. Restart plack and try the endpoint
=> FAIL: A generic error is displayed, and no traces of the original
problem are found on the logs.
3. Apply this patches, make sure your instance's log4perl has the
   introduced lines for API with the right path.
4. Repeat 2
=> SUCCESS: The message is still generic, but you see something is
logged in /var/log/koha/kohadev/api-error.log
5. Discuss the approach on the bug, with special attention on:
   - Can Koha::Logger be used in Mojo like that? It seems so
   - How the heck can we write tests for the change in V1.pm?
   - Do you really like what I put in the log? Should we change that?
     That was just the first thing that crossed my mind so ideas are
     welcome.

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


More information about the Koha-bugs mailing list