Bug 25493: Make ->unhandled_exception use Koha::Logger
authorTomas Cohen Arazi <tomascohen@theke.io>
Wed, 13 May 2020 20:17:21 +0000 (17:17 -0300)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Tue, 19 May 2020 14:20:43 +0000 (15:20 +0100)
commitb3ed9a40426bec52c1da9334818c49a6cbcfb464
tree3b45e125e276c127607cfc856ece9331d2e6757a
parentc97921bb68849a2c7dd5f2f5ad8f5b97789df5c1
Bug 25493: Make ->unhandled_exception use Koha::Logger

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
=> SUCCESS: The message is generic, but you see something is
logged in /var/log/koha/kohadev/api-error.log
3. Change die("Nada"); for a real exception like:

    use Koha::Exceptions;
    Koha::Exceptions::DuplicateObject->throw("Nada");
4. Repeat 2.
=> SUCCESS: The message is generic, but a meaningful text is added to
the logs.
5. Point your browser to the /api/v1/hola route from your dev
   environment
=> FAIL: Wow, such a weird error
6. Apply this patch
7. Restart plack and repeat 2, 3 and 4
=> SUCCESS: No behaviour change
8. Repeat 5
=> SUCCESS: The regular Mojolicious 404 weird page
9. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Koha/REST/Plugin/Exceptions.pm
Koha/REST/V1.pm