Koha::Schema::Util::ExceptionTranslator - Centralized DBIx::Class exception translation
use Koha::Schema::Util::ExceptionTranslator;
try {
# DBIx::Class operation that might fail
$schema->resultset('SomeTable')->create(\%data);
} catch {
Koha::Schema::Util::ExceptionTranslator->translate_exception($_, \%columns_info);
};
This utility class provides centralized exception translation from DBIx::Class exceptions to Koha-specific exceptions. This eliminates the need for duplicated exception handling code throughout the codebase.
Koha::Schema::Util::ExceptionTranslator->translate_exception($exception, $columns_info);
Translates a DBIx::Class exception into an appropriate Koha exception and throws it. If the exception cannot be translated, it rethrows the original exception.
$exception - The caught exception object$columns_info (optional) - Hash reference of column information for enhanced error reportingKoha::Exceptions::Object::FKConstraintKoha::Exceptions::Object::DuplicateIDKoha::Exceptions::Object::BadValueKoha::Exceptions::Object::BadValueThis utility is designed to be extended to support:
Koha Development Team