Bug 28056: Add Koha::Exceptions::Patron::MissingMandatoryExtendedAttribute
This trivial patch adds a new exception for more fine-grained control on the errors when dealing with patrons and their extended attributes. To test: 1. Apply this patches 2. Run: $ kshell k$ prove t/Koha/Exceptions.t => SUCCESS: Tests pass! 3. Sign off :-D Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
3ee844ff56
commit
f2b3099a9f
|
|
@ -7,11 +7,62 @@ use Exception::Class (
|
|||
description => "Something went wrong!"
|
||||
},
|
||||
'Koha::Exceptions::Patron::FailedDelete' => {
|
||||
isa => 'Koha::Exceptions::Patron',
|
||||
description => "Deleting patron failed"
|
||||
},
|
||||
'Koha::Exceptions::Patron::FailedDeleteAnonymousPatron' => {
|
||||
isa => 'Koha::Exceptions::Patron',
|
||||
description => "Deleting patron failed, AnonymousPatron is not deleteable"
|
||||
},
|
||||
'Koha::Exceptions::Patron::MissingMandatoryExtendedAttribute' => {
|
||||
isa => 'Koha::Exceptions::Patron',
|
||||
description => "Mandatory extended attribute missing",
|
||||
fields => ['type']
|
||||
}
|
||||
);
|
||||
|
||||
sub full_message {
|
||||
my $self = shift;
|
||||
|
||||
my $msg = $self->message;
|
||||
|
||||
unless ( $msg) {
|
||||
if ( $self->isa('Koha::Exceptions::Patron::MissingMandatoryExtendedAttribute') ) {
|
||||
$msg = sprintf("Missing mandatory extended attribute (type=%s)", $self->type );
|
||||
}
|
||||
}
|
||||
|
||||
return $msg;
|
||||
}
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Koha::Exceptions::Patron - Base class for patron exceptions
|
||||
|
||||
=head1 Exceptions
|
||||
|
||||
=head2 Koha::Exceptions::Patron
|
||||
|
||||
Generic patron exception.
|
||||
|
||||
=head2 Koha::Exceptions::Patron::FailedDelete
|
||||
|
||||
Deleting patron failed.
|
||||
|
||||
=head2 Koha::Exceptions::Patron::FailedDeleteAnonymousPatron
|
||||
|
||||
Tried to delete the anonymous patron.
|
||||
|
||||
=head2 Koha::Exceptions::Patron::MissingMandatoryExtendedAttribute
|
||||
|
||||
A required mandatory extended attribute is missing.
|
||||
|
||||
=head1 Class methods
|
||||
|
||||
=head2 full_message
|
||||
|
||||
Overloaded method for exception stringifying.
|
||||
|
||||
=cut
|
||||
|
||||
1;
|
||||
|
|
|
|||
Loading…
Reference in New Issue