Bugzilla – Attachment 128916 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), 1.90 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-12-27 11:33:55 UTC
(
hide
)
Description:
Bug 28020: Add error_code to error responses
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-12-27 11:33:55 UTC
Size:
1.90 KB
patch
obsolete
>From 4d91ff1e99438d2b3383562a5e8252bbdb8251a8 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> >--- > 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 e9be043aa2..b069711596 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 8576374a8b..8f52da4c13 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.34.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