Browse Source

Bug 25504: Use Koha::Logger and display the full stacktrace

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
20.11.x
Jonathan Druart 4 years ago
parent
commit
f9ab4f0aac
  1. 4
      Koha/REST/Plugin/PluginRoutes.pm
  2. 6
      Koha/REST/V1.pm

4
Koha/REST/Plugin/PluginRoutes.pm

@ -21,6 +21,7 @@ use Mojo::Base 'Mojolicious::Plugin';
use Koha::Exceptions::Plugin;
use Koha::Plugins;
use Koha::Logger;
use Clone qw(clone);
use Try::Tiny;
@ -91,7 +92,8 @@ sub inject_routes {
catch {
my $error = $_;
my $class = ref $plugin;
warn "Plugin $class route injection failed: $error";
my $logger = Koha::Logger->get({ interface => 'api' });
$logger->error("Plugin $class route injection failed: $error");
return $spec;
};
}

6
Koha/REST/V1.pm

@ -20,6 +20,7 @@ use Modern::Perl;
use Mojo::Base 'Mojolicious';
use C4::Context;
use Koha::Logger;
use Carp;
use JSON::Validator::OpenAPI::Mojolicious;
use Try::Tiny;
@ -106,7 +107,8 @@ sub startup {
# to catch bad ones.
# JSON::Validator uses confess, so trim call stack from the message.
carp "Warning: Could not load REST API spec bundle: " . ($_ =~ /\A(.*?)$/ms)[0];
my $logger = Koha::Logger->get({ interface => 'api' });
$logger->error("Warning: Could not load REST API spec bundle: " . $_);
try {
$validator->load_and_validate_schema(
@ -138,7 +140,7 @@ sub startup {
}
catch {
# JSON::Validator uses confess, so trim call stack from the message.
croak "Could not load REST API spec: " . ($_ =~ /\A(.*?)$/ms)[0];
$logger->error("Warning: Could not load REST API spec bundle: " . $_);
};
};

Loading…
Cancel
Save