Bugzilla – Attachment 180930 Details for
Bug 39632
Failed plugin install gives too little info
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39632: Extend plugin exceptions with more useful parameters
Bug-39632-Extend-plugin-exceptions-with-more-usefu.patch (text/plain), 3.93 KB, created by
Tomás Cohen Arazi (tcohen)
on 2025-04-14 19:21:25 UTC
(
hide
)
Description:
Bug 39632: Extend plugin exceptions with more useful parameters
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2025-04-14 19:21:25 UTC
Size:
3.93 KB
patch
obsolete
>From 3357630a7eea97d5e5c5707cd7e2cf9a6cba9314 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Tom=C3=A1s=20Cohen=20Arazi?= <tomas@bywatersolutions.com> >Date: Mon, 14 Apr 2025 16:08:42 -0300 >Subject: [PATCH] Bug 39632: Extend plugin exceptions with more useful > parameters > >This patch tweaks the `Koha::Exceptions::Plugin` class by adding an >extra parameter to the plugin install and upgrade related exceptions so >they carry the actuall error (if any). > >* Koha::Exceptions::Plugin::InstallDied: install_error >* Koha::Exceptions::Plugin::UpgradeDied: upgrade_error > >I didn't pick plain 'error' because it is a reserved word for >`Exception::Class` which makes it stringify using its value only. > >To test: >1. Apply this patch >2. Run: > $ ktd --shell > k$ prove t/Koha/Exceptions.t >=> SUCCESS: Tests pass! >3. Sign off :-D >--- > Koha/Exceptions/Plugin.pm | 8 ++++---- > t/Koha/Exceptions.t | 15 +++++++++++---- > 2 files changed, 15 insertions(+), 8 deletions(-) > >diff --git a/Koha/Exceptions/Plugin.pm b/Koha/Exceptions/Plugin.pm >index 585e89cbbd5..4293ccc5347 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 37a48a2c413..592af87b65f 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 { >-- >2.49.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 39632
:
180930
|
180931
|
180942
|
180943