From 2f33e5b587f9f0b4b9b45af67d4897b901b1053b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tadeusz=20=E2=80=9Etadzik=E2=80=9D=20So=C5=9Bnierz?= Date: Fri, 23 Jan 2026 15:07:17 +0100 Subject: [PATCH] Bug 41696: Generalize additem.pl/tt's error handling This prevents us from losing track of errors and failing quietly. --- cataloguing/additem.pl | 6 +-- .../prog/en/modules/cataloguing/additem.tt | 37 +++++++++++++------ 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index 5c3e200512..4d4ff5dc06 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -646,7 +646,7 @@ if ( $op eq "cud-additem" ) { try { $item->store; } catch { - push @errors, $_->error; + push @errors, $_; } } @@ -838,7 +838,5 @@ if ( $frameworkcode eq 'FA' ) { ); } -foreach my $error (@errors) { - $template->param( $error => 1 ); -} +$template->param( errors => \@errors ); output_html_with_http_headers $input, $cookie, $template->output; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt index 76758d3deb..5d8dc06bf2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt @@ -89,18 +89,33 @@

Items for [% biblio.title | html %] [% IF ( biblio.author ) %]by [% biblio.author | html %][% END %] (Record #[% biblio.biblionumber | html %])

Jump to form - [% IF ( onloan_cannot_withdraw ) %]
Error saving item: Onloan item cannot be withdrawn.
[% END %] - [% IF ( intransit_cannot_withdraw ) %]
Error saving item: In transit item cannot be withdrawn.
[% END %] - [% IF ( barcode_not_unique ) %]
Error saving item: Barcode must be unique.
[% END %] - [% IF ( no_next_barcode ) %]
Error saving items: Unable to automatically determine values for barcodes. No item has been inserted.
[% END %] - [% IF ( book_on_loan ) %]
Cannot delete: item is checked out.
[% END %] - [% IF ( book_reserved ) %]
Cannot delete: item has a waiting hold.
[% END %] - [% IF ( not_same_branch ) %]
Cannot delete: The items do not belong to your library.
[% END %] - [% IF ( linked_analytics ) %] -
Cannot delete: item has linked analytics..
+ [% FOREACH error IN errors %] +
+ [% IF error == 'onloan_cannot_withdraw' %] + Error saving item: Onloan item cannot be withdrawn. + [% ELSIF error == 'intransit_cannot_withdraw' %] + Error saving item: In transit item cannot be withdrawn. + [% ELSIF error == 'barcode_not_unique' %] + Error saving item: Barcode must be unique. + [% ELSIF error == 'no_next_barcode' %] + Error saving items: Unable to automatically determine values for barcodes. No item has been inserted. + [% ELSIF error == 'book_on_loan' %] + Cannot delete: item is checked out. + [% ELSIF error == 'book_reserved' %] + Cannot delete: item has a waiting hold. + [% ELSIF error == 'not_same_branch' %] + Cannot delete: The items do not belong to your library. + [% ELSIF error == 'linked_analytics' %] + Cannot delete: item has linked analytics.. + [% ELSIF error == 'last_item_for_hold' %] + Cannot delete: Last item for bibliographic record with biblio-level hold on it. + [% ELSIF error == 'item_not_found' %] + Cannot delete: Item not found. + [% ELSE %] + Error: [% error %]. + [% END %] +
[% END %] - [% IF last_item_for_hold %]
Cannot delete: Last item for bibliographic record with biblio-level hold on it.
[% END %] - [% IF item_not_found %]
Cannot delete: Item not found.
[% END %]
[% IF items %] -- 2.51.0