Bug 33028: Make exception less generic
While testing this bug I found Circulation.t was failing, but the exception doesn't actually display anything useful in terms of helping debug what's going on. This patch makes it add the rule_name and rule_value to the message. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
82bdaa8fbc
commit
9b7c077c9d
2 changed files with 35 additions and 1 deletions
|
@ -21,6 +21,7 @@ use Modern::Perl;
|
|||
use Carp qw( croak );
|
||||
|
||||
use Koha::Exceptions;
|
||||
use Koha::Exceptions::CirculationRule;
|
||||
use Koha::CirculationRule;
|
||||
use Koha::Caches;
|
||||
use Koha::Cache::Memory::Lite;
|
||||
|
@ -381,7 +382,7 @@ sub set_rule {
|
|||
my $can_be_blank = defined $kind_info->{can_be_blank} ? $kind_info->{can_be_blank} : 1;
|
||||
$rule_value = undef if defined $rule_value && $rule_value eq "" && !$can_be_blank;
|
||||
my $is_monetary = defined $kind_info->{is_monetary} ? $kind_info->{is_monetary} : 0;
|
||||
Koha::Exceptions::BadParameter->throw("set_rule expected decimal")
|
||||
Koha::Exceptions::CirculationRule::NotDecimal->throw( name => $rule_name, value => $rule_value )
|
||||
if ( $is_monetary && defined($rule_value) && $rule_value !~ /^\d+(\.\d{2})?$/ );
|
||||
|
||||
for my $v ( $branchcode, $categorycode, $itemtype ) {
|
||||
|
|
33
Koha/Exceptions/CirculationRule.pm
Normal file
33
Koha/Exceptions/CirculationRule.pm
Normal file
|
@ -0,0 +1,33 @@
|
|||
package Koha::Exceptions::CirculationRule;
|
||||
|
||||
# This file is part of Koha.
|
||||
#
|
||||
# Koha is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Koha is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Koha; if not, see <http://www.gnu.org/licenses>.
|
||||
|
||||
use Modern::Perl;
|
||||
|
||||
use Koha::Exception;
|
||||
|
||||
use Exception::Class (
|
||||
'Koha::Exceptions::CirculationRule' => {
|
||||
isa => 'Koha::Exception',
|
||||
},
|
||||
'Koha::Exceptions::CirculationRule::NotDecimal' => {
|
||||
isa => 'Koha::Exceptions::CirculationRule',
|
||||
description => "The circulation rule expected a decimal value",
|
||||
fields => [ 'name', 'value' ],
|
||||
},
|
||||
);
|
||||
|
||||
1;
|
Loading…
Reference in a new issue