Bug 21022: Use passed message if present
[koha.git] / Koha / Exceptions / Exception.pm
1 package Koha::Exceptions::Exception;
2
3 use Modern::Perl;
4
5 # Looks like this class should be more Koha::Exception::Base;
6 use Exception::Class (
7     'Koha::Exceptions::Exception' => {
8         description => "Something went wrong!"
9     },
10 );
11
12 # We want to overload it to have a stringification method for our exceptions
13 sub full_message {
14     my $self = shift;
15
16     my $msg = $self->message;
17
18     unless ( $msg) {
19         if ( $self->isa('Koha::Exceptions::Object::FKConstraint') ) {
20             $msg = sprintf("Invalid parameter passed, %s=%s does not exist", $self->broken_fk, $self->value );
21         }
22     }
23
24     return $msg;
25 }
26
27 1;