1 package Koha::Exceptions::Patron::Relationship;
3 # This file is part of Koha.
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.
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.
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>.
20 use Exception::Class (
22 'Koha::Exceptions::Patron::Relationship' => {
23 description => 'Something went wrong!',
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' ]
30 'Koha::Exceptions::Patron::Relationship::InvalidRelationship' => {
31 isa => 'Koha::Exceptions::Patron::Relationship',
32 description => 'The specified relationship is invalid',
33 fields => ['relationship','no_relationship']
40 my $msg = $self->message;
43 if ( $self->isa('Koha::Exceptions::Patron::Relationship::InvalidRelationship') ) {
44 if ( $self->no_relationship ) {
45 $msg = sprintf( "No relationship passed." );
48 $msg = sprintf("Invalid relationship passed, '%s' is not defined.", $self->relationship );
51 elsif ( $self->isa('Koha::Exceptions::Patron::Relationship::DuplicateRelationship') ) {
54 "There already exists a relationship for the same guarantor (%s) and guarantee (%s) combination",
55 $self->guarantor_id, $self->guarantee_id );
64 Koha::Exceptions::Patron::Relationship - Base class for patron relatioship exceptions
68 =head2 Koha::Exceptions::Patron::Relationship
70 Generic Patron exception
72 =head2 Koha::Exceptions::Patron::Relationship::DuplicateRelationship
74 Exception to be used when more than one relationship is requested for a
75 pair of patrons in the same direction.
77 =head2 Koha::Exceptions::Patron::Relationship::InvalidRelationship
79 Exception to be used when an invalid relationship is passed.
85 Overloaded method for exception stringifying.