Bug 22099: Fixed ILL toolbar to say Refresh when displaying requests
[koha.git] / Koha / Exceptions / Object.pm
blobd36d9dc5fcef2108b4d9c81d8a749baec7e60dc2
1 package Koha::Exceptions::Object;
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
8 # version.
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.
18 use Modern::Perl;
20 use Koha::Exceptions::Exception;
22 use Exception::Class (
23 'Koha::Exceptions::Object' => {
24 isa => 'Koha::Exceptions::Exception',
26 'Koha::Exceptions::Object::DuplicateID' => {
27 isa => 'Koha::Exceptions::Object',
28 description => "Duplicate ID passed",
29 fields => ['duplicate_id']
31 'Koha::Exceptions::Object::FKConstraint' => {
32 isa => 'Koha::Exceptions::Object',
33 description => "Foreign key constraint broken",
34 fields => ['broken_fk', 'value'],
36 'Koha::Exceptions::Object::MethodNotFound' => {
37 isa => 'Koha::Exceptions::Object',
38 description => "Invalid method",
40 'Koha::Exceptions::Object::PropertyNotFound' => {
41 isa => 'Koha::Exceptions::Object',
42 description => "Invalid property",
44 'Koha::Exceptions::Object::MethodNotCoveredByTests' => {
45 isa => 'Koha::Exceptions::Object',
46 description => "Method not covered by tests",
48 'Koha::Exceptions::Object::BadValue' => {
49 isa => 'Koha::Exceptions::Object',
50 description => 'Invalid data passed',
51 fields => ['type', 'property', 'value'],
55 sub full_message {
56 my $self = shift;
58 my $msg = $self->message;
60 unless ( $msg) {
61 if ( $self->isa('Koha::Exceptions::Object::FKConstraint') ) {
62 $msg = sprintf("Invalid parameter passed, %s=%s does not exist", $self->broken_fk, $self->value );
64 elsif ( $self->isa('Koha::Exceptions::Object::BadValue') ) {
65 $msg = sprintf("Invalid value passed, %s=%s expected type is %s", $self->property, $self->value, $self->type );
69 return $msg;
72 =head1 NAME
74 Koha::Exceptions::Object - Base class for Object exceptions
76 =head1 Exceptions
78 =head2 Koha::Exceptions::Object
80 Generic Object exception
82 =head2 Koha::Exceptions::Object::DuplicateID
84 Exception to be used when a duplicate ID is passed.
86 =head2 Koha::Exceptions::Object::FKConstraint
88 Exception to be used when a foreign key constraint is broken.
90 =head2 Koha::Exceptions::Object::MethodNotFound
92 Exception to be used when an invalid class method has been invoked.
94 =head2 Koha::Exceptions::Object::PropertyNotFound
96 Exception to be used when an invalid object property has been requested.
98 =head2 Koha::Exceptions::Object::MethodNotCoveredByTests
100 Exception to be used when the invoked method is not covered by tests.
102 =head2 Koha::Exceptions::Object::BadValue
104 Exception to be used when a bad value has been passed for a property.
106 =head1 Class methods
108 =head2 full_message
110 Overloaded method for exception stringifying.
112 =cut