https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42391
--- Comment #13 from Kyle M Hall (khall) <[email protected]> --- Created attachment 198620 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=198620&action=edit Bug 42391: Use exception_action to translate DBIC exceptions at the source DBIx::Class provides an exception_action hook that intercepts every throw_exception call before it becomes a DBIx::Class::Exception. By installing this hook on Koha::Schema via a connection() override, all database exceptions are automatically translated into Koha exceptions at the source. This eliminates the need for translate_exception catch blocks in every caller: - Remove try/catch from Koha::Object::store - Remove try/catch from Koha::Object::delete - Remove try/catch from Koha::Item::add_to_bundle - Remove translate_exception convenience method from Koha::Schema - Remove safe_do (already removed in previous follow-up) ExceptionTranslator is refactored to work on plain error message strings instead of DBIx::Class::Exception objects, since exception_action receives the message before wrapping. Unmatched errors fall through to DBIx::Class::Exception->throw() as the default, preserving backward compatibility. The warn $_->{msg} that was in Object::store is no longer needed since exceptions are translated before they propagate. Tests that asserted on that warning (via warning_like) are updated to use throws_ok directly. Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Schema/Util/ExceptionTranslator.t => SUCCESS: Tests pass! k$ prove t/db_dependent/Koha/Object.t => SUCCESS: Tests pass! k$ prove t/db_dependent/Koha/Item.t => SUCCESS: Tests pass! k$ prove t/db_dependent/Koha/Patron/Modifications.t => SUCCESS: Tests pass! 3. Sign off :-D Signed-off-by: David Nind <[email protected]> Signed-off-by: Kyle M Hall <[email protected]> -- You are receiving this mail because: You are watching all bug changes. _______________________________________________ Koha-bugs mailing list [email protected] https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
