From cf3bcb8ccf061a5dba9f8aee8cd0dd9506b2a610 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 15 Oct 2021 08:46:33 -0300 Subject: [PATCH] Bug 24609: (QA follow-up) Cleaner handling of unhandled exceptions This patch updates how we handle unhandled exceptions nowadays in Koha controllers. It also adds a missing call to ->discard_changes for the returned object. Signed-off-by: Tomas Cohen Arazi --- Koha/REST/V1/Checkouts.pm | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/Koha/REST/V1/Checkouts.pm b/Koha/REST/V1/Checkouts.pm index 1063ea264f..7b9d4502ea 100644 --- a/Koha/REST/V1/Checkouts.pm +++ b/Koha/REST/V1/Checkouts.pm @@ -227,23 +227,14 @@ sub update { my $params = $c->req->json; $checkout->set_from_api( $params ); $checkout->store(); + $checkout->discard_changes; return $c->render( status => 200, openapi => $checkout->to_api ); } catch { - unless ( blessed $_ && $_->can('rethrow') ) { - return $c->render( - status => 500, - openapi => { error => "Something went wrong, check Koha logs for details." } - ); - } - - return $c->render( - status => 500, - openapi => { error => "$_" } - ); + $c->unhandled_exception($_); }; } -- 2.32.0