Bug 36088: Remove useless code form opac-account-pay.pl
[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::MissingEmailAddress' => {
12         description => "Patron has no email address",
13     },
14     'Koha::Exceptions::Patron::FailedDelete' => {
15         isa         => 'Koha::Exceptions::Patron',
16         description => "Deleting patron failed"
17     },
18     'Koha::Exceptions::Patron::FailedAnonymizing' => {
19         isa         => 'Koha::Exceptions::Patron',
20         description => "Anonymizing patron reading history failed"
21     },
22     'Koha::Exceptions::Patron::FailedDeleteAnonymousPatron' => {
23         isa         => 'Koha::Exceptions::Patron',
24         description => "Deleting patron failed, AnonymousPatron is not deleteable"
25     },
26     'Koha::Exceptions::Patron::FailedDeleteProtectedPatron' => {
27         isa         => 'Koha::Exceptions::Patron',
28         description => "Deleting patron failed, patron is protected"
29     },
30     'Koha::Exceptions::Patron::InvalidUserid' => {
31         isa         => 'Koha::Exceptions::Patron',
32         description => 'Field userid is not valid (probably not unique)',
33         fields      => [ 'userid' ],
34     },
35     'Koha::Exceptions::Patron::MissingMandatoryExtendedAttribute' => {
36         isa         => 'Koha::Exceptions::Patron',
37         description => "Mandatory extended attribute missing",
38         fields      => ['type']
39     },
40     'Koha::Exceptions::Patron::NotFound' => {
41         isa => 'Koha::Exceptions::Patron',
42         description => "Patron not found"
43     },
44 );
45
46 sub full_message {
47     my $self = shift;
48
49     my $msg = $self->message;
50
51     unless ( $msg) {
52         if ( $self->isa('Koha::Exceptions::Patron::MissingMandatoryExtendedAttribute') ) {
53             $msg = sprintf("Missing mandatory extended attribute (type=%s)", $self->type );
54         }
55     }
56
57     return $msg;
58 }
59
60 =head1 NAME
61
62 Koha::Exceptions::Patron - Base class for patron exceptions
63
64 =head1 Exceptions
65
66 =head2 Koha::Exceptions::Patron
67
68 Generic patron exception.
69
70 =head2 Koha::Exceptions::Patron::FailedDelete
71
72 Deleting patron failed.
73
74 =head2 Koha::Exceptions::Patron::FailedDeleteAnonymousPatron
75
76 Tried to delete the anonymous patron.
77
78 =head2 Koha::Exceptions::Patron::MissingMandatoryExtendedAttribute
79
80 A required mandatory extended attribute is missing.
81
82 =head1 Class methods
83
84 =head2 full_message
85
86 Overloaded method for exception stringifying.
87
88 =cut
89
90 1;