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 under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 3 of the License, or (at your option) any later
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along
15 # with Koha; if not, write to the Free Software Foundation, Inc.,
16 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
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.