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 Koha::Exceptions::Exception;
22 use Exception::Class (
24 'Koha::Exceptions::Patron::Relationship' => {
25 isa => 'Koha::Exceptions::Exception',
27 'Koha::Exceptions::Patron::Relationship::DuplicateRelationship' => {
28 isa => 'Koha::Exceptions::Patron::Relationship',
29 description => 'There can only be one relationship between patrons in a direction',
30 fields => [ 'guarantor_id', 'guarantee_id' ]
32 'Koha::Exceptions::Patron::Relationship::InvalidRelationship' => {
33 isa => 'Koha::Exceptions::Patron::Relationship',
34 description => 'The specified relationship is invalid',
35 fields => ['relationship','no_relationship']
42 my $msg = $self->message;
45 if ( $self->isa('Koha::Exceptions::Patron::Relationship::InvalidRelationship') ) {
46 if ( $self->no_relationship ) {
47 $msg = sprintf( "No relationship passed." );
50 $msg = sprintf("Invalid relationship passed, '%s' is not defined.", $self->relationship );
53 elsif ( $self->isa('Koha::Exceptions::Patron::Relationship::DuplicateRelationship') ) {
56 "There already exists a relationship for the same guarantor (%s) and guarantee (%s) combination",
57 $self->guarantor_id, $self->guarantee_id );
66 Koha::Exceptions::Patron::Relationship - Base class for patron relatioship exceptions
70 =head2 Koha::Exceptions::Patron::Relationship
72 Generic Patron exception
74 =head2 Koha::Exceptions::Patron::Relationship::DuplicateRelationship
76 Exception to be used when more than one relationship is requested for a
77 pair of patrons in the same direction.
79 =head2 Koha::Exceptions::Patron::Relationship::InvalidRelationship
81 Exception to be used when an invalid relationship is passed.
87 Overloaded method for exception stringifying.