Bug 39632 - Failed plugin install gives too little info
Summary: Failed plugin install gives too little info
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Plugin architecture (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Tomás Cohen Arazi (tcohen)
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-04-14 18:48 UTC by Tomás Cohen Arazi (tcohen)
Modified: 2025-04-14 21:18 UTC (History)
3 users (show)

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 39632: Extend plugin exceptions with more useful parameters (3.93 KB, patch)
2025-04-14 19:21 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 39632: Make plugin install and upgrade errors more useful (2.54 KB, patch)
2025-04-14 19:21 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 39632: Extend plugin exceptions with more useful parameters (3.99 KB, patch)
2025-04-14 21:18 UTC, Brendan Gallagher
Details | Diff | Splinter Review
Bug 39632: Make plugin install and upgrade errors more useful (2.60 KB, patch)
2025-04-14 21:18 UTC, Brendan Gallagher
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Tomás Cohen Arazi (tcohen) 2025-04-14 18:48:23 UTC
When the `install()` process fails, it throws a `Koha::Exceptions::Plugin::InstallDied` exception. But it only carries the `plugin_class` value. We need to pass the error from the `try/catch` block so it gets returned to the caller as well.
Comment 1 Tomás Cohen Arazi (tcohen) 2025-04-14 19:21:25 UTC
Created attachment 180930 [details] [review]
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
Comment 2 Tomás Cohen Arazi (tcohen) 2025-04-14 19:21:27 UTC
Created attachment 180931 [details] [review]
Bug 39632: Make plugin install and upgrade errors more useful

This patch makes the install and upgrade process for plugins to add the
newly added extra parameters to the thrown exceptions.

This is covered by the tests

To test:
1. Apply this patch
2. Run:
   $ ktd --shell
  k$ prove -r t/Koha/Exceptions.t \
           t/db_dependent/Koha/Plugins
=> SUCCESS: Tests pass!
3. Sign off :-D
Comment 3 Brendan Gallagher 2025-04-14 21:18:28 UTC
Created attachment 180942 [details] [review]
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

Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
Comment 4 Brendan Gallagher 2025-04-14 21:18:30 UTC
Created attachment 180943 [details] [review]
Bug 39632: Make plugin install and upgrade errors more useful

This patch makes the install and upgrade process for plugins to add the
newly added extra parameters to the thrown exceptions.

This is covered by the tests

To test:
1. Apply this patch
2. Run:
   $ ktd --shell
  k$ prove -r t/Koha/Exceptions.t \
           t/db_dependent/Koha/Plugins
=> SUCCESS: Tests pass!
3. Sign off :-D

Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>