Bug 29857: Rename base class as Koha::Exception
[koha.git] / Koha / Exceptions / Patron.pm
1 package Koha::Exceptions::Patron;
2
3 use Modern::Perl;
4
5 use Koha::Exception;
6
7 use Exception::Class (
8     'Koha::Exceptions::Patron' => {
9         isa => 'Koha::Exception',
10     },
11     'Koha::Exceptions::Patron::FailedDelete' => {
12         isa         => 'Koha::Exceptions::Patron',
13         description => "Deleting patron failed"
14     },
15     'Koha::Exceptions::Patron::FailedDeleteAnonymousPatron' => {
16         isa         => 'Koha::Exceptions::Patron',
17         description => "Deleting patron failed, AnonymousPatron is not deleteable"
18     },
19     'Koha::Exceptions::Patron::MissingMandatoryExtendedAttribute' => {
20         isa         => 'Koha::Exceptions::Patron',
21         description => "Mandatory extended attribute missing",
22         fields      => ['type']
23     }
24 );
25
26 sub full_message {
27     my $self = shift;
28
29     my $msg = $self->message;
30
31     unless ( $msg) {
32         if ( $self->isa('Koha::Exceptions::Patron::MissingMandatoryExtendedAttribute') ) {
33             $msg = sprintf("Missing mandatory extended attribute (type=%s)", $self->type );
34         }
35     }
36
37     return $msg;
38 }
39
40 =head1 NAME
41
42 Koha::Exceptions::Patron - Base class for patron exceptions
43
44 =head1 Exceptions
45
46 =head2 Koha::Exceptions::Patron
47
48 Generic patron exception.
49
50 =head2 Koha::Exceptions::Patron::FailedDelete
51
52 Deleting patron failed.
53
54 =head2 Koha::Exceptions::Patron::FailedDeleteAnonymousPatron
55
56 Tried to delete the anonymous patron.
57
58 =head2 Koha::Exceptions::Patron::MissingMandatoryExtendedAttribute
59
60 A required mandatory extended attribute is missing.
61
62 =head1 Class methods
63
64 =head2 full_message
65
66 Overloaded method for exception stringifying.
67
68 =cut
69
70 1;