View | Details | Raw Unified | Return to bug 21022
Collapse All | Expand All

(-)a/Koha/Exceptions/Exception.pm (-15 lines)
Lines 9-27 use Exception::Class ( Link Here
9
    },
9
    },
10
);
10
);
11
11
12
# We want to overload it to have a stringification method for our exceptions
13
sub full_message {
14
    my $self = shift;
15
16
    my $msg = $self->message;
17
18
    unless ( $msg) {
19
        if ( $self->isa('Koha::Exceptions::Object::FKConstraint') ) {
20
            $msg = sprintf("Invalid parameter passed, %s=%s does not exist", $self->broken_fk, $self->value );
21
        }
22
    }
23
24
    return $msg;
25
}
26
27
1;
12
1;
(-)a/Koha/Exceptions/Object.pm (-1 / +67 lines)
Lines 1-5 Link Here
1
package Koha::Exceptions::Object;
1
package Koha::Exceptions::Object;
2
2
3
# This file is part of Koha.
4
#
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.
9
#
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.
13
#
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.
17
3
use Modern::Perl;
18
use Modern::Perl;
4
19
5
use Koha::Exceptions::Exception;
20
use Koha::Exceptions::Exception;
Lines 32-35 use Exception::Class ( Link Here
32
    },
47
    },
33
);
48
);
34
49
50
sub full_message {
51
    my $self = shift;
52
53
    my $msg = $self->message;
54
55
    unless ( $msg) {
56
        if ( $self->isa('Koha::Exceptions::Object::FKConstraint') ) {
57
            $msg = sprintf("Invalid parameter passed, %s=%s does not exist", $self->broken_fk, $self->value );
58
        }
59
    }
60
61
    return $msg;
62
}
63
64
=head1 NAME
65
66
Koha::Exceptions::Object - Base class for Object exceptions
67
68
=head1 Exceptions
69
70
=head2 Koha::Exceptions::Object
71
72
Generic Object exception
73
74
=head2 Koha::Exceptions::Object::DuplicateID
75
76
Exception to be used when a duplicate ID is passed.
77
78
=head2 Koha::Exceptions::Object::FKConstraint
79
80
Exception to be used when a foreign key constraint is broken.
81
82
=head2 Koha::Exceptions::Object::MethodNotFound
83
84
Exception to be used when an invalid class method has been invoked.
85
86
=head2 Koha::Exceptions::Object::PropertyNotFound
87
88
Exception to be used when an invalid object property has been requested.
89
90
=head2 Koha::Exceptions::Object::MethodNotCoveredByTests
91
92
Exception to be used when the invoked method is not covered by tests.
93
94
=head1 Class methods
95
96
=head2 full_message
97
98
Overloaded method for exception stringifying.
99
100
=cut
101
35
1;
102
1;
36
- 

Return to bug 21022