From d3c575b84e27dc747bf04fa0e343f4ef9f6f3785 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Sun, 21 Sep 2025 15:35:09 +0100 Subject: [PATCH] Bug 19871: Update virtualshelf templates to use Koha exceptions instead of DBIx::Class::Exception Replace DBIx::Class::Exception handling in shelf templates with specific Koha exception types that are now provided by the centralized exception translation system. Template changes: - Replace 'DBIx::Class::Exception' case with specific Koha exception handlers - Add user-friendly error messages for FKConstraint, DuplicateID, and BadValue - Improve error presentation with descriptive text instead of raw database errors This provides better user experience by showing meaningful error messages instead of technical database exception details. Sponsored-by: OpenFifth Signed-off-by: Jackie Usher --- .../prog/en/modules/virtualshelves/shelves.tt | 8 ++++++-- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt index 65047eb133b..b0d800fd6bf 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt @@ -191,8 +191,12 @@ An error occurred when creating this list. The name [% shelfname | html %] already exists. [% CASE 'Koha::Exceptions::Virtualshelf::UseDbAdminAccount' %] List could not be created. (Do not use the database administrator account.) - [% CASE 'DBIx::Class::Exception' %] - [% m.msg | html %] + [% CASE 'Koha::Exceptions::Object::FKConstraint' %] + Database constraint error: [% m.msg | html %] + [% CASE 'Koha::Exceptions::Object::DuplicateID' %] + Duplicate entry error: [% m.msg | html %] + [% CASE 'Koha::Exceptions::Object::BadValue' %] + Invalid data error: [% m.msg | html %] [% CASE %] [% m.code | html %] [% m.msg | html %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt index 78629f1e38a..808883bc7a5 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt @@ -235,8 +235,12 @@ The new owner has no share for this list. [% CASE 'Koha::Exceptions::Virtualshelf::DuplicateObject' %] An error occurred when creating the list. The name [% shelfname | html %] already exists. - [% CASE 'DBIx::Class::Exception' %] - [% m.msg | html %] + [% CASE 'Koha::Exceptions::Object::FKConstraint' %] + Database constraint error: [% m.msg | html %] + [% CASE 'Koha::Exceptions::Object::DuplicateID' %] + Duplicate entry error: [% m.msg | html %] + [% CASE 'Koha::Exceptions::Object::BadValue' %] + Invalid data error: [% m.msg | html %] [% CASE %] [% m.code | html %] [% m.msg | html %] -- 2.53.0