Bug 29857: Rename base class as Koha::Exception
[koha.git] / Koha / Exception.pm
1 package Koha::Exception;
2
3 use Modern::Perl;
4
5 use Exception::Class (
6     'Koha::Exception' => {
7         description => "Something went wrong!"
8     },
9 );
10
11 sub full_message {
12     my $self = shift;
13     my $msg = $self->description;
14     my @fields;
15     my $field_hash = $self->field_hash;
16     while ( my ( $field, $value ) = each %$field_hash ) {
17         push @fields, $field . " => " . $value;
18     }
19     return
20       sprintf "Exception '%s' thrown '%s'" . ( @fields ? " with %s" : "" ) . "\n",
21       ref($self), $msg, ( @fields ? join ', ', @fields : () );
22 }
23
24 1;