From d76d42841095945d3044f43bce0ec9fac3482e76 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Tue, 11 Apr 2023 12:45:13 +0000 Subject: [PATCH] Bug 33482: Unsupported Media Type exception in packages patch method This adds the Unsupported Media Type exception error code and error message to the UI --- Koha/ERM/Providers/EBSCO.pm | 2 ++ Koha/REST/V1/ERM/EHoldings/Packages/EBSCO.pm | 7 ++++++- api/v1/swagger/paths/erm_eholdings_packages.yaml | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Koha/ERM/Providers/EBSCO.pm b/Koha/ERM/Providers/EBSCO.pm index 38217b5fa29..6aa848a7ff9 100644 --- a/Koha/ERM/Providers/EBSCO.pm +++ b/Koha/ERM/Providers/EBSCO.pm @@ -277,6 +277,8 @@ sub request { Koha::Exceptions::ObjectNotFound->throw($message); } elsif ( $response->code == 401 ) { Koha::Exceptions::Authorization::Unauthorized->throw($message); + } elsif ( $response->code == 415 ) { + Koha::Exceptions::UnsupportedMediaType->throw($message); } else { die sprintf "ERROR requesting EBSCO API\n%s\ncode %s: %s\n", $url, $response->code, $message; diff --git a/Koha/REST/V1/ERM/EHoldings/Packages/EBSCO.pm b/Koha/REST/V1/ERM/EHoldings/Packages/EBSCO.pm index 8c65c087064..fd2ea9315b0 100644 --- a/Koha/REST/V1/ERM/EHoldings/Packages/EBSCO.pm +++ b/Koha/REST/V1/ERM/EHoldings/Packages/EBSCO.pm @@ -151,7 +151,12 @@ sub edit { status => 404, openapi => { error => $_->error } ); - + } + if ( $_->isa('Koha::Exceptions::UnsupportedMediaType') ) { + return $c->render( + status => 415, + openapi => { error => $_->error } + ); } } diff --git a/api/v1/swagger/paths/erm_eholdings_packages.yaml b/api/v1/swagger/paths/erm_eholdings_packages.yaml index 51899e33162..ace0674cdc2 100644 --- a/api/v1/swagger/paths/erm_eholdings_packages.yaml +++ b/api/v1/swagger/paths/erm_eholdings_packages.yaml @@ -391,6 +391,10 @@ description: Package not found schema: $ref: "../swagger.yaml#/definitions/error" + 415: + description: Unsupported Media Type + schema: + $ref: "../swagger.yaml#/definitions/error" 500: description: |- Internal server error. Possible `error_code` attribute values: -- 2.30.2