Bugzilla – Attachment 153620 Details for
Bug 33028
Wrongly formatted monetary amounts in circulation rules break scripts and calculations
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33028: Make exception less generic
Bug-33028-Make-exception-less-generic.patch (text/plain), 2.98 KB, created by
Tomás Cohen Arazi (tcohen)
on 2023-07-18 18:38:04 UTC
(
hide
)
Description:
Bug 33028: Make exception less generic
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2023-07-18 18:38:04 UTC
Size:
2.98 KB
patch
obsolete
>From 8e96b550c579e6d414af67478ab80a8e221a201d Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 18 Jul 2023 15:05:50 -0300 >Subject: [PATCH] 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> >--- > Koha/CirculationRules.pm | 3 ++- > Koha/Exceptions/CirculationRule.pm | 33 ++++++++++++++++++++++++++++++ > 2 files changed, 35 insertions(+), 1 deletion(-) > create mode 100644 Koha/Exceptions/CirculationRule.pm > >diff --git a/Koha/CirculationRules.pm b/Koha/CirculationRules.pm >index 8065cf827f5..8518aa6112a 100644 >--- a/Koha/CirculationRules.pm >+++ b/Koha/CirculationRules.pm >@@ -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 ) { >diff --git a/Koha/Exceptions/CirculationRule.pm b/Koha/Exceptions/CirculationRule.pm >new file mode 100644 >index 00000000000..a43d248a430 >--- /dev/null >+++ b/Koha/Exceptions/CirculationRule.pm >@@ -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; >-- >2.41.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 33028
:
147058
|
147686
|
147687
|
147688
|
152441
|
152442
|
152443
|
152444
|
152445
|
152446
|
152509
|
152510
|
152511
|
152512
|
152513
|
152514
|
152515
|
152752
|
152753
|
152754
|
152755
|
152756
|
152757
|
152758
|
152759
|
152760
|
152761
|
152762
|
152763
|
152764
|
152803
|
152804
|
152805
|
152829
|
152928
|
152929
|
152930
|
152931
|
152932
|
152933
|
152934
|
152935
|
152936
|
153313
|
153314
|
153315
|
153316
|
153317
|
153318
|
153319
|
153320
|
153321
|
153322
|
153323
|
153619
| 153620 |
153632
|
153633
|
153634
|
153635
|
153636
|
153677