From 6f2be2594eeb161a95f76a4eee247392f7d493b6 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. --- .../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 cf5f68b3e19..0c173b89c83 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 875a88da234..8e3a3bbe760 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt @@ -210,8 +210,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.51.0