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