From 0797d9cc09fdb8e0f1b1e0b5824775ff6286c60a Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 19 Apr 2018 10:50:33 -0300 Subject: [PATCH] Bug 20590: Koha::Exceptions::Exception Signed-off-by: Jonathan Druart --- Koha/Exceptions/Exception.pm | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Koha/Exceptions/Exception.pm diff --git a/Koha/Exceptions/Exception.pm b/Koha/Exceptions/Exception.pm new file mode 100644 index 0000000000..6768587613 --- /dev/null +++ b/Koha/Exceptions/Exception.pm @@ -0,0 +1,25 @@ +package Koha::Exceptions::Exception; + +use Modern::Perl; + +# Looks like this class should be more Koha::Exception::Base; +use Exception::Class ( + 'Koha::Exceptions::Exception' => { + description => "Something went wrong!" + }, +); + +# We want to overload it to have a stringification method for our exceptions +sub full_message { + my $self = shift; + + my $msg = $self->message; + + if ( $self->isa('Koha::Exceptions::Object::FKConstraint') ) { + $msg = sprintf("Invalid parameter passed, %s=%s does not exist", $self->broken_fk, $self->value ); + } + + return $msg; +} + +1; -- 2.11.4.GIT