Bugzilla – Attachment 128962 Details for
Bug 28020
Error responses should return a code
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28020: Add error_code to error responses
Bug-28020-Add-errorcode-to-error-responses.patch (text/plain), 2.04 KB, created by
Jonathan Druart
on 2022-01-03 13:39:15 UTC
(
hide
)
Description:
Bug 28020: Add error_code to error responses
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-01-03 13:39:15 UTC
Size:
2.04 KB
patch
obsolete
>From cc82d3569748bf45f67b9734839e41925a5483cc Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 27 Dec 2021 08:27:24 -0300 >Subject: [PATCH] Bug 28020: Add error_code to error responses > >This patch adds the *error_code* attribute to the error response >definition. This way it can be added when returning an error. > >I also made a sample usage of it on the generic unhandled_exception >helper, which the unit tests on this patchset expect. > >To test: >1. Apply the unit tests patch >2. Run: > $ kshell > k$ prove t/db_dependent/api/v1/unhandled_exceptions.t >=> FAIL: The unhandled_exception() helper doesn't return an error_code >in the response payload. >3. Apply this patch >4. Repeat 2 >=> SUCCESS: Tests pass! > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > Koha/REST/Plugin/Exceptions.pm | 6 +++--- > api/v1/swagger/definitions/error.yaml | 3 +++ > 2 files changed, 6 insertions(+), 3 deletions(-) > >diff --git a/Koha/REST/Plugin/Exceptions.pm b/Koha/REST/Plugin/Exceptions.pm >index e9be043aa2b..b0697115964 100644 >--- a/Koha/REST/Plugin/Exceptions.pm >+++ b/Koha/REST/Plugin/Exceptions.pm >@@ -76,11 +76,11 @@ sub register { > status => 500, > openapi => { > error => >- "Something went wrong, check Koha logs for details." >+ "Something went wrong, check Koha logs for details.", >+ error_code => 'internal_server_error', > } > ); >- } >- >+ } > ); > } > >diff --git a/api/v1/swagger/definitions/error.yaml b/api/v1/swagger/definitions/error.yaml >index 8576374a8b5..8f52da4c137 100644 >--- a/api/v1/swagger/definitions/error.yaml >+++ b/api/v1/swagger/definitions/error.yaml >@@ -4,4 +4,7 @@ properties: > error: > description: Error message > type: string >+ error_code: >+ description: Error code >+ type: string > additionalProperties: true >-- >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 28020
:
128915
|
128916
|
128917
|
128918
|
128919
|
128920
|
128921
|
128922
|
128923
|
128961
| 128962 |
128963