Bugzilla – Attachment 85716 Details for
Bug 18206
REST API: Default exception handling
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18206: Use this feature for cities
Bug-18206-Use-this-feature-for-cities.patch (text/plain), 3.16 KB, created by
Josef Moravec
on 2019-02-26 12:55:07 UTC
(
hide
)
Description:
Bug 18206: Use this feature for cities
Filename:
MIME Type:
Creator:
Josef Moravec
Created:
2019-02-26 12:55:07 UTC
Size:
3.16 KB
patch
obsolete
>From 57a01d5d38bbbc3a9c000f9409d66dcd53d4b40a Mon Sep 17 00:00:00 2001 >From: Lari Taskula <lari.taskula@jns.fi> >Date: Tue, 14 Mar 2017 18:19:58 +0200 >Subject: [PATCH] Bug 18206: Use this feature for cities > >To test: >1. prove t/db_dependent/api/v1/cities.t > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> >--- > Koha/REST/V1/Cities.pm | 45 +++++++++++---------------------------------- > 1 file changed, 11 insertions(+), 34 deletions(-) > >diff --git a/Koha/REST/V1/Cities.pm b/Koha/REST/V1/Cities.pm >index 8bca97cc65..032ce0acf3 100644 >--- a/Koha/REST/V1/Cities.pm >+++ b/Koha/REST/V1/Cities.pm >@@ -18,6 +18,7 @@ package Koha::REST::V1::Cities; > use Mojo::Base 'Mojolicious::Controller'; > > use Koha::Cities; >+use Koha::Exceptions; > > use Try::Tiny; > >@@ -38,14 +39,7 @@ sub list { > 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."} ); >- } >+ Koha::Exceptions::rethrow_exception($_); > }; > > } >@@ -79,18 +73,7 @@ sub add { > return $c->render( status => 200, openapi => _to_api($city->TO_JSON) ); > } > 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." } >- ); >- } >+ Koha::Exceptions::rethrow_exception($_); > }; > } > >@@ -115,14 +98,11 @@ sub update { > return $c->render( status => 200, openapi => _to_api($city->TO_JSON) ); > } > catch { >- if ( $_->isa('Koha::Exceptions::Object') ) { >- return $c->render( status => 500, >- openapi => { error => $_->message } ); >- } >- else { >- return $c->render( status => 500, >- openapi => { error => "Something went wrong, check the logs."} ); >+ if ( not defined $city ) { >+ return $c->render( status => 404, >+ openapi => { error => "Object not found" } ); > } >+ Koha::Exceptions::rethrow_exception($_); > }; > } > >@@ -144,14 +124,11 @@ sub delete { > return $c->render( status => 200, openapi => "" ); > } > 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."} ); >+ if ( not defined $city ) { >+ return $c->render( status => 404, >+ openapi => { error => "Object not found" } ); > } >+ Koha::Exceptions::rethrow_exception($_); > }; > } > >-- >2.11.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 18206
:
61072
|
61073
|
61087
|
61088
|
61170
|
61171
|
68243
|
69229
|
69230
|
69231
|
85715
| 85716 |
85717