Bug 24545: Fix license statements
[koha.git] / Koha / Exceptions / Patron / Relationship.pm
1 package Koha::Exceptions::Patron::Relationship;
2
3 # This file is part of Koha.
4 #
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18 use Modern::Perl;
19
20 use Exception::Class (
21
22     'Koha::Exceptions::Patron::Relationship' => {
23         description => 'Something went wrong!',
24     },
25     'Koha::Exceptions::Patron::Relationship::DuplicateRelationship' => {
26         isa         => 'Koha::Exceptions::Patron::Relationship',
27         description => 'There can only be one relationship between patrons in a direction',
28         fields      => [ 'guarantor_id', 'guarantee_id' ]
29     },
30     'Koha::Exceptions::Patron::Relationship::InvalidRelationship' => {
31         isa         => 'Koha::Exceptions::Patron::Relationship',
32         description => 'The specified relationship is invalid',
33         fields      =>  ['relationship','no_relationship']
34     }
35 );
36
37 sub full_message {
38     my $self = shift;
39
40     my $msg = $self->message;
41
42     unless ( $msg) {
43         if ( $self->isa('Koha::Exceptions::Patron::Relationship::InvalidRelationship') ) {
44             if ( $self->no_relationship ) {
45                 $msg = sprintf( "No relationship passed." );
46             }
47             else {
48                 $msg = sprintf("Invalid relationship passed, '%s' is not defined.", $self->relationship );
49             }
50         }
51         elsif ( $self->isa('Koha::Exceptions::Patron::Relationship::DuplicateRelationship') ) {
52             $msg
53                 = sprintf(
54                 "There already exists a relationship for the same guarantor (%s) and guarantee (%s) combination",
55                 $self->guarantor_id, $self->guarantee_id );
56         }
57     }
58
59     return $msg;
60 }
61
62 =head1 NAME
63
64 Koha::Exceptions::Patron::Relationship - Base class for patron relatioship exceptions
65
66 =head1 Exceptions
67
68 =head2 Koha::Exceptions::Patron::Relationship
69
70 Generic Patron exception
71
72 =head2 Koha::Exceptions::Patron::Relationship::DuplicateRelationship
73
74 Exception to be used when more than one relationship is requested for a
75 pair of patrons in the same direction.
76
77 =head2 Koha::Exceptions::Patron::Relationship::InvalidRelationship
78
79 Exception to be used when an invalid relationship is passed.
80
81 =head1 Class methods
82
83 =head2 full_message
84
85 Overloaded method for exception stringifying.
86
87 =cut
88
89 1;