diff --git a/Koha/Exceptions/Plugin.pm b/Koha/Exceptions/Plugin.pm index 585e89cbbd..4293ccc534 100644 --- a/Koha/Exceptions/Plugin.pm +++ b/Koha/Exceptions/Plugin.pm @@ -35,12 +35,12 @@ use Exception::Class ( 'Koha::Exceptions::Plugin::InstallDied' => { isa => 'Koha::Exceptions::Plugin', description => 'The plugin died on install', - fields => ['plugin_class'], + fields => [ 'plugin_class', 'install_error' ], }, 'Koha::Exceptions::Plugin::UpgradeDied' => { isa => 'Koha::Exceptions::Plugin', description => 'The plugin died on upgrade', - fields => ['plugin_class'], + fields => [ 'plugin_class', 'upgrade_error' ], }, ); @@ -56,9 +56,9 @@ sub full_message { $self->plugin_name, $self->method ); } elsif ( $self->isa('Koha::Exceptions::Plugin::InstallDied') ) { - $msg = sprintf( "Calling 'install' died for plugin %s", $self->plugin_class ); + $msg = sprintf( "Calling 'install' died for plugin %s: %s", $self->plugin_class, $self->install_error ); } elsif ( $self->isa('Koha::Exceptions::Plugin::UpgradeDied') ) { - $msg = sprintf( "Calling 'upgrade' died for plugin %s", $self->plugin_class ); + $msg = sprintf( "Calling 'upgrade' died for plugin %s: %s", $self->plugin_class, $self->upgrade_error ); } } diff --git a/t/Koha/Exceptions.t b/t/Koha/Exceptions.t index 37a48a2c41..592af87b65 100755 --- a/t/Koha/Exceptions.t +++ b/t/Koha/Exceptions.t @@ -315,24 +315,31 @@ subtest 'Koha::Exceptions::Plugin tests' => sub { use_ok("Koha::Exceptions::Plugin"); my $plugin_class = 'yahey'; + my $error_string = 'This is an error'; throws_ok { - Koha::Exceptions::Plugin::InstallDied->throw( plugin_class => $plugin_class ); + Koha::Exceptions::Plugin::InstallDied->throw( + plugin_class => $plugin_class, + install_error => $error_string, + ); } 'Koha::Exceptions::Plugin::InstallDied', 'Exception is thrown :-D'; # stringify the exception - is( "$@", "Calling 'install' died for plugin $plugin_class", 'Exception stringified correctly' ); + is( "$@", "Calling 'install' died for plugin $plugin_class: $error_string", 'Exception stringified correctly' ); throws_ok { - Koha::Exceptions::Plugin::UpgradeDied->throw( plugin_class => $plugin_class ); + Koha::Exceptions::Plugin::UpgradeDied->throw( + plugin_class => $plugin_class, + upgrade_error => $error_string, + ); } 'Koha::Exceptions::Plugin::UpgradeDied', 'Exception is thrown :-D'; # stringify the exception - is( "$@", "Calling 'upgrade' died for plugin $plugin_class", 'Exception stringified correctly' ); + is( "$@", "Calling 'upgrade' died for plugin $plugin_class: $error_string", 'Exception stringified correctly' ); }; subtest 'Koha::Exceptions::Booking tests' => sub {