https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42391 Bug ID: 42391 Summary: Use DBIx::Class exception_action to translate exceptions at the source Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: koha-bugs@lists.koha-community.org Reporter: tomascohen@gmail.com QA Contact: testopia@bugs.koha-community.org Depends on: 19871 Bug 19871 introduced Koha::Schema::Util::ExceptionTranslator to centralize the translation of DBIx::Class exceptions into Koha exceptions. Currently, each caller (Object::store, Object::delete, Item::add_to_bundle) must explicitly call translate_exception in its catch block. DBIx::Class provides an exception_action hook on the Schema that intercepts every throw_exception call before it becomes a DBIx::Class::Exception. By setting this hook on Koha::Schema, we could translate MySQL errors into Koha exceptions at the source, eliminating the need for catch-block boilerplate in every caller. This would: - Remove the translate_exception catch blocks from Object::store, Object::delete, and Item::add_to_bundle - Make every DBIC operation (including raw resultset calls) automatically produce Koha exceptions without caller intervention - Close the gap where unmatched DBIx::Class::Exception errors could slip through template error handlers (identified during QA of bug 19871) - Refactor ExceptionTranslator to work on plain error strings instead of exception objects (exception_action receives the message before wrapping) The exception_action hook is available in DBIx::Class 0.082844 (shipped with KTD) and has been a core feature since early DBIC versions. Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19871 [Bug 19871] Use new exceptions Koha::Exceptions::Object::DuplicateID and FKConstraint -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.