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>
my $message = "$method $path: unhandled exception $type\<\<$exception_string\>\>";
- $c->app->log->error("$message");
+ my $logger = Koha::Logger->get({ interface => 'api' });
+ $logger->error("$message");
$c->render(
status => 500,
sub startup {
my $self = shift;
- $self->log( Koha::Logger->get({ interface => 'api' }) );
-
$self->hook(
before_dispatch => sub {
my $c = shift;
$self->types->type( mij => 'application/marc-in-json' );
$self->types->type( marc => 'application/marc' );
-
my $secret_passphrase = C4::Context->config('api_secret_passphrase');
if ($secret_passphrase) {
$self->secrets([$secret_passphrase]);