Bugzilla – Attachment 117377 Details for
Bug 27806
Exceptions thrown during a call to ->render are not caught and passed to ->unhandled_exception
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27806: (follow-up) Attempt to catch the exception
Bug-27806-follow-up-Attempt-to-catch-the-exception.patch (text/plain), 1.79 KB, created by
Martin Renvoize
on 2021-02-26 13:29:13 UTC
(
hide
)
Description:
Bug 27806: (follow-up) Attempt to catch the exception
Filename:
MIME Type:
Creator:
Martin Renvoize
Created:
2021-02-26 13:29:13 UTC
Size:
1.79 KB
patch
obsolete
>From 98da178eb233eefa90cbbb50ca687ae697597f2d Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 25 Feb 2021 15:22:35 +0000 >Subject: [PATCH] Bug 27806: (follow-up) Attempt to catch the exception > >Help: I'm struggling to catch the point at which the exception should be >thrown to convert it to a 400 error response in the API. '->search' does >not actually trigger the DB hit until we reference some data from it.. >so we can't use that.. so I tried '->count', but of course.. that drops >'order_by' which is the failure in this case and so we pass through. >--- > Koha/REST/Plugin/Exceptions.pm | 15 ++++++++++----- > 1 file changed, 10 insertions(+), 5 deletions(-) > >diff --git a/Koha/REST/Plugin/Exceptions.pm b/Koha/REST/Plugin/Exceptions.pm >index e9be043aa2..e56f2b28ea 100644 >--- a/Koha/REST/Plugin/Exceptions.pm >+++ b/Koha/REST/Plugin/Exceptions.pm >@@ -54,16 +54,21 @@ sub register { > $app->helper( > 'unhandled_exception' => sub { > my ( $c, $exception ) = @_; >+ warn "Inside unhandled_exception\n"; > >- my $req = $c->req; >- my $method = $req->method; >- my $path = $req->url->to_abs->path; > my $type = ""; >- > if ( blessed $exception ) { >- $type = "(" . ref($exception) . ")"; >+ if ( $exception->isa('Koha::Exceptions::Object::PropertyNotFound') ) { >+ $c->render( status => 400, json => $_->error ); >+ } else { >+ $type = "(" . ref($exception) . ")"; >+ } > } > >+ my $req = $c->req; >+ my $method = $req->method; >+ my $path = $req->url->to_abs->path; >+ > my $exception_string = "$exception"; > chomp($exception_string); > >-- >2.20.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 27806
:
117376
| 117377