From 484406124117abb3d7b256b3d741f22187d421fa Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 31 Mar 2021 08:59:10 -0300 Subject: [PATCH] Bug 23666: (follow-up) Adjust to new exceptions Signed-off-by: Tomas Cohen Arazi --- Koha/REST/V1/Patrons/Attributes.pm | 7 ++----- t/db_dependent/api/v1/patrons_extended_attributes.t | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Koha/REST/V1/Patrons/Attributes.pm b/Koha/REST/V1/Patrons/Attributes.pm index 75a43aa9c8b..f769765a738 100644 --- a/Koha/REST/V1/Patrons/Attributes.pm +++ b/Koha/REST/V1/Patrons/Attributes.pm @@ -205,13 +205,10 @@ sub overwrite { openapi => { error => "$_" } ); } - elsif ( $_->isa('Koha::Exceptions::Object::FKConstraint') ) { + elsif ( $_->isa('Koha::Exceptions::Patron::MissingMandatoryExtendedAttribute') ) { return $c->render( status => 400, - openapi => { - error => 'Missing mandatory attribute of type "' - . $_->value . '".' - } + openapi => { error => "$_" } ); } diff --git a/t/db_dependent/api/v1/patrons_extended_attributes.t b/t/db_dependent/api/v1/patrons_extended_attributes.t index 7de141a5d1a..1766576fcb4 100755 --- a/t/db_dependent/api/v1/patrons_extended_attributes.t +++ b/t/db_dependent/api/v1/patrons_extended_attributes.t @@ -301,7 +301,7 @@ subtest 'overwrite() tests' => sub { . '/extended_attributes' => json => [ { type => $unique_attr_type->code, value => $value_1 } ] ) ->status_is(400) - ->json_is( '/error' => 'Missing mandatory attribute of type "' . $mandatory_attr_type->code . '".' ); + ->json_is( '/error' => "Missing mandatory extended attribute (type=" . $mandatory_attr_type->code . ')' ); $patron->add_extended_attribute({ code => $repeatable_attr_type->code, attribute => 'repeatable_1' }); $patron->add_extended_attribute({ code => $repeatable_attr_type->code, attribute => 'repeatable_2' }); -- 2.31.1