Bugzilla – Attachment 74560 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.13 KB, created by
Tomás Cohen Arazi (tcohen)
on 2018-04-19 14:26:18 UTC
(
hide
)
Description:
Bug 20590: Improve Koha::Exceptions in string context
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2018-04-19 14:26:18 UTC
Size:
3.13 KB
patch
obsolete
>From 6550afe3599d80c7804d4e0da8f96ba160b0573b 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 > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > C4/Members.pm | 6 +++--- > Koha/Exceptions.pm | 5 +---- > Koha/Exceptions/Object.pm | 5 ++--- > 3 files changed, 6 insertions(+), 10 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', >-- >2.17.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