[Koha-bugs] [Bug 25032] Generic unhandled exception handling

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Thu Apr 2 19:37:53 CEST 2020


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25032

--- Comment #4 from Tomás Cohen Arazi <tomascohen at gmail.com> ---
(In reply to Jonathan Druart from comment #3)
> I cannot test this, I get this scary message on /api/v1/app.pl

I don't know why are you pointing your API tool there or if it is related to
this or not. If you want to bypass the rewrite rules we have, the right path to
get to the API is:

GET /api/v1/app.pl/api/v1

You will get the current spec in JSON format. You can request 

GET /api/v1/app.pl/api/v1/.html

to get a nicer (?) HTML formatted spec.

That said, WTF? Just use

GET /api/v1/

instead :-D

:-D

> And cities returns "error" (basically).

This is the change I made to try this patch:

diff --git a/Koha/REST/V1/Cities.pm b/Koha/REST/V1/Cities.pm
index 4c49e1a346..8c45a9031e 100644
--- a/Koha/REST/V1/Cities.pm
+++ b/Koha/REST/V1/Cities.pm
@@ -37,17 +37,11 @@ sub list {
     return try {
         my $cities_set = Koha::Cities->new;
         my $cities = $c->objects->search( $cities_set );
+        die "Nada";
         return $c->render( status => 200, openapi => $cities );
     }
     catch {
-        if ( $_->isa('DBIx::Class::Exception') ) {
-            return $c->render( status  => 500,
-                               openapi => { error => $_->{msg} } );
-        }
-        else {
-            return $c->render( status => 500,
-                openapi => { error => "Something went wrong, check the logs."}
);
-        }
+        $c->unhandled_exception($_);
     };

 }

I will submit a follow-up patch with the changes for the Cities.pm controller
class so we look at the same thing. I will ommit the die "Nada"; line.

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list