Bugzilla – Attachment 74246 Details for
Bug 20590
Koha::Exceptions does not stringify the exceptions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20590: Improve Koha::Exceptions in string context
Bug-20590-Improve-KohaExceptions-in-string-context.patch (text/plain), 3.65 KB, created by
Jonathan Druart
on 2018-04-16 15:45:11 UTC
(
hide
)
Description:
Bug 20590: Improve Koha::Exceptions in string context
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2018-04-16 15:45:11 UTC
Size:
3.65 KB
patch
obsolete
>From 8eb5078b3f1dae8ecc50d364723d8b0c04a67f67 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 16 Apr 2018 12:39:15 -0300 >Subject: [PATCH] Bug 20590: Improve Koha::Exceptions in string context > >I was working on bug 20580 and noticed that the exceptions are not >stringified and so not really useful when displayed in string context. > >This patch is for discussion and not ready for inclusion > >Still need to fix: >Koha/REST/V1/Patrons.pm (The error is "Given xxx does not exist") >Koha/Object.pm: in ->store, Koha::Exceptions::Object::FKConstraint is >raised but we cannot set 'value' > >Another note: In Koha::Exceptions::Exception I do not have access to >$self->line_number and $self->filename > >See also >http://search.cpan.org/~drolsky/Exception-Class-1.44/lib/Exception/Class/Base.pm#OVERRIDING_THE_as_string_METHOD > >Test plan: >Apply patch from bug 20580 and execute create_superlibrarian.pl with an >invalid categorycode >--- > C4/Members.pm | 6 +++--- > Koha/Exceptions.pm | 5 +---- > Koha/Exceptions/Object.pm | 5 ++--- > Koha/Object.pm | 1 - > 4 files changed, 6 insertions(+), 11 deletions(-) > >diff --git a/C4/Members.pm b/C4/Members.pm >index f4fd79e1dc..a901a961bc 100644 >--- a/C4/Members.pm >+++ b/C4/Members.pm >@@ -400,9 +400,9 @@ sub AddMember { > > my $category = Koha::Patron::Categories->find( $data{categorycode} ); > unless ($category) { >- Koha::Exceptions::BadParameter->throw( >- error => 'Invalid parameter passed', >- parameter => 'categorycode' >+ Koha::Exceptions::Object::FKConstraint->throw( >+ broken_fk => 'categorycode', >+ value => $data{categorycode}, > ); > } > >diff --git a/Koha/Exceptions.pm b/Koha/Exceptions.pm >index f49a289901..72a56cc3af 100644 >--- a/Koha/Exceptions.pm >+++ b/Koha/Exceptions.pm >@@ -1,13 +1,10 @@ > package Koha::Exceptions; > > use Modern::Perl; >+use Koha::Exceptions::Exception; > > use Exception::Class ( > >- # General exceptions >- 'Koha::Exceptions::Exception' => { >- description => 'Something went wrong!', >- }, > 'Koha::Exceptions::BadParameter' => { > isa => 'Koha::Exceptions::Exception', > description => 'A bad parameter was given', >diff --git a/Koha/Exceptions/Object.pm b/Koha/Exceptions/Object.pm >index 4cad568347..451c677c5f 100644 >--- a/Koha/Exceptions/Object.pm >+++ b/Koha/Exceptions/Object.pm >@@ -3,9 +3,8 @@ package Koha::Exceptions::Object; > use Modern::Perl; > > use Exception::Class ( >- > 'Koha::Exceptions::Object' => { >- description => 'Something went wrong!', >+ isa => 'Koha::Exceptions::Exception', > }, > 'Koha::Exceptions::Object::DuplicateID' => { > isa => 'Koha::Exceptions::Object', >@@ -15,7 +14,7 @@ use Exception::Class ( > 'Koha::Exceptions::Object::FKConstraint' => { > isa => 'Koha::Exceptions::Object', > description => "Foreign key constraint broken", >- fields => ['broken_fk'] >+ fields => ['broken_fk', 'value'], > }, > 'Koha::Exceptions::Object::MethodNotFound' => { > isa => 'Koha::Exceptions::Object', >diff --git a/Koha/Object.pm b/Koha/Object.pm >index 00e0c243a8..b883832eb9 100644 >--- a/Koha/Object.pm >+++ b/Koha/Object.pm >@@ -131,7 +131,6 @@ sub store { > # FIXME: MySQL error, if we support more DB engines we should implement this for each > if ( $_->{msg} =~ /FOREIGN KEY \(`(?<column>.*?)`\)/ ) { > Koha::Exceptions::Object::FKConstraint->throw( >- error => 'Broken FK constraint', > broken_fk => $+{column} > ); > } >-- >2.11.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 20590
:
74246
|
74556
|
74560
|
74561
|
74562
|
74563
|
74583
|
74639