Bug 27145: Rethrow all other exceptions

Bug 14708 introduced a try catch around $patron->delete in commit:
  "Bug 14708: (QA follow-up) Use try/catch blocks when calling"

However, in the catch block it only assumes the exception was from trying to
delete anonymous patron when it can be anything else as well, the code should
be modified so that it will handle the anonymous patron case and if it is
anything else we log the other exception.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Kyle M Hall 2020-12-03 09:10:30 -05:00 committed by Kyle Hall
parent 51d17c422a
commit df47a2e195
1 changed files with 8 additions and 2 deletions

View File

@ -133,8 +133,14 @@ if ( $op eq 'delete_confirm' or $countissues > 0 or $debits or $is_guarantor ) {
try {
$patron->delete;
print $input->redirect("/cgi-bin/koha/members/members-home.pl");
} catch {
print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE_ANONYMOUS_PATRON");
}
catch {
if ( $_->isa('Koha::Exceptions::Patron::FailedDeleteAnonymousPatron') ) {
print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE_ANONYMOUS_PATRON");
}
else {
$_->rethrow;
}
};
# TODO Tell the user everything went ok
exit 0; # Exit without error