From 1ab6def4da1c9110fe94b259c8eca4bf64e2558d Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 30 Mar 2021 11:03:09 -0300 Subject: [PATCH] Bug 27857: (use-it-in-real-life follow-up) Use a more fine-grained exception for mandatory attributes Signed-off-by: Tomas Cohen Arazi --- Koha/Patron.pm | 5 ++--- t/db_dependent/Koha/Patron.t | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 1160084ca63..f24ad0f8552 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -1578,9 +1578,8 @@ sub extended_attributes { { join => 'borrower_attribute_types_branches' } )->get_column('class'); for my $type ( @required_attribute_types ) { - Koha::Exceptions::Object::FKConstraint->throw( - broken_fk => "$type", - value => "$type", + Koha::Exceptions::Patron::MissingMandatoryExtendedAttribute->throw( + type => $type, ) if !$new_types->{$type}; } } diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t index 98b079f4c33..d17fd77a04d 100755 --- a/t/db_dependent/Koha/Patron.t +++ b/t/db_dependent/Koha/Patron.t @@ -644,7 +644,7 @@ subtest 'extended_attributes' => sub { ] ); } - 'Koha::Exceptions::Object::FKConstraint', + 'Koha::Exceptions::Patron::MissingMandatoryExtendedAttribute', 'Exception thrown on missing mandatory attribute type'; is( $patron->extended_attributes->count, 0, 'Extended attributes storing rolled back' ); -- 2.31.1