Bugzilla – Attachment 129330 Details for
Bug 29857
We must stringify our exceptions correctly
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29857: Provide a generic full_message method for our exceptions
Bug-29857-Provide-a-generic-fullmessage-method-for.patch (text/plain), 1.37 KB, created by
Jonathan Druart
on 2022-01-12 09:34:34 UTC
(
hide
)
Description:
Bug 29857: Provide a generic full_message method for our exceptions
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-01-12 09:34:34 UTC
Size:
1.37 KB
patch
obsolete
>From 729391ee25abeb40215158d58deba37c028431fe Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 12 Jan 2022 10:30:59 +0100 >Subject: [PATCH] Bug 29857: Provide a generic full_message method for our > exceptions > >We pass useful information when throwing exceptions, but we don't >display them! We must display all the details we need when the exception >is stringified. > >Test plan: > >Use the following snippet: > use Koha::Exceptions::Elasticsearch; > Koha::Exceptions::Elasticsearch::BadResponse->throw( type => "a good type", details => "and some details" ); > >Execute it without and with the patch. >--- > Koha/Exceptions/Exception.pm | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > >diff --git a/Koha/Exceptions/Exception.pm b/Koha/Exceptions/Exception.pm >index 8955ea9e6ee..5dfe20f7ef4 100644 >--- a/Koha/Exceptions/Exception.pm >+++ b/Koha/Exceptions/Exception.pm >@@ -9,4 +9,17 @@ use Exception::Class ( > }, > ); > >+sub full_message { >+ my $self = shift; >+ my $msg = $self->description; >+ my @fields; >+ my $field_hash = $self->field_hash; >+ while ( my ( $field, $value ) = each %$field_hash ) { >+ push @fields, $field . " => " . $value; >+ } >+ return >+ sprintf "Exception '%s' thrown '%s'" . ( @fields ? " with %s" : "" ) . "\n", >+ ref($self), $msg, ( @fields ? join ', ', @fields : () ); >+} >+ > 1; >-- >2.25.1
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 29857
:
129329
|
129330
|
130007
|
130008
|
130009
|
130010
|
130011
|
130012
|
130013
|
130014
|
130015
|
130156
|
130157
|
130158
|
130355
|
131112
|
131113
|
131114
|
131115
|
131116
|
131117
|
131232
|
131240
|
131241
|
131242
|
131243
|
131244
|
131256
|
131258
|
131287
|
131288
|
131289
|
131290
|
131291