|
Lines 8-20
use Exception::Class (
Link Here
|
| 8 |
description => 'Something went wrong' |
8 |
description => 'Something went wrong' |
| 9 |
}, |
9 |
}, |
| 10 |
'Koha::Exceptions::Patron::Attribute::NonRepeatable' => { |
10 |
'Koha::Exceptions::Patron::Attribute::NonRepeatable' => { |
| 11 |
isa => 'Koha::Exceptions::Patron::Attribute', |
11 |
isa => 'Koha::Exceptions::Patron::Attribute', |
| 12 |
description => "repeatable not set for attribute type and tried to add a new attribute for the same code" |
12 |
description => "repeatable not set for attribute type and tried to add a new attribute for the same code", |
|
|
13 |
fields => [ "attribute" ] |
| 13 |
}, |
14 |
}, |
| 14 |
'Koha::Exceptions::Patron::Attribute::UniqueIDConstraint' => { |
15 |
'Koha::Exceptions::Patron::Attribute::UniqueIDConstraint' => { |
| 15 |
isa => 'Koha::Exceptions::Patron::Attribute', |
16 |
isa => 'Koha::Exceptions::Patron::Attribute', |
| 16 |
description => "unique_id set for attribute type and tried to add a new with the same code and value" |
17 |
description => "unique_id set for attribute type and tried to add a new with the same code and value", |
|
|
18 |
fields => [ "attribute" ] |
| 17 |
} |
19 |
} |
| 18 |
); |
20 |
); |
| 19 |
|
21 |
|
|
|
22 |
sub full_message { |
| 23 |
my $self = shift; |
| 24 |
|
| 25 |
my $msg = $self->message; |
| 26 |
|
| 27 |
unless ( $msg) { |
| 28 |
if ( $self->isa('Koha::Exceptions::Patron::Attribute::NonRepeatable') ) { |
| 29 |
$msg = sprintf( |
| 30 |
"Tried to add more than one non-repeatable attributes. code=%s attribute=%s", |
| 31 |
$self->attribute->code, |
| 32 |
$self->attribute->attribute |
| 33 |
); |
| 34 |
} |
| 35 |
elsif ( $self->isa('Koha::Exceptions::Patron::Attribute::UniqueIDConstraint') ) { |
| 36 |
$msg = sprintf( |
| 37 |
"Your action breaks a unique constraint on the attribute. code=%s attribute=%s", |
| 38 |
$self->attribute->code, |
| 39 |
$self->attribute->attribute |
| 40 |
); |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
return $msg; |
| 45 |
} |
| 46 |
|
| 47 |
=head1 NAME |
| 48 |
|
| 49 |
Koha::Exceptions::Patron::Attribute - Base class for patron attribute exceptions |
| 50 |
|
| 51 |
=head1 Exceptions |
| 52 |
|
| 53 |
=head2 Koha::Exceptions::Patron::Attribute |
| 54 |
|
| 55 |
Generic patron attribute exception |
| 56 |
|
| 57 |
=head2 Koha::Exceptions::Patron::Attribute::NonRepeatable |
| 58 |
|
| 59 |
Exception to be used trying to add more than one non-repeatable attribute. |
| 60 |
|
| 61 |
=head2 Koha::Exceptions::Patron::Attribute::UniqueIDConstraint |
| 62 |
|
| 63 |
Exception to be used when trying to add an attribute that breaks its type unique constraint. |
| 64 |
|
| 65 |
=head1 Class methods |
| 66 |
|
| 67 |
=head2 full_message |
| 68 |
|
| 69 |
Overloaded method for exception stringifying. |
| 70 |
|
| 71 |
=cut |
| 72 |
|
| 20 |
1; |
73 |
1; |