Skip to content

Commit

Permalink
EKIR-213 Raise the new error
Browse files Browse the repository at this point in the history
  • Loading branch information
natlibfi-kaisa committed Sep 18, 2024
1 parent 1932ced commit 93cf672
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions api/controller/loan.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
PatronHoldLimitReached,
PatronLoanLimitReached,
RemoteRefusedReturn,
NoAvailableCopiesWhenReserved
)
from api.controller.circulation_manager import CirculationManagerController
from api.problem_details import (
Expand Down Expand Up @@ -203,6 +204,11 @@ def _borrow(self, patron, credential, pool, mechanism):
result = e.as_problem_detail_document(debug=False)
except CannotLoan as e:
result = CHECKOUT_FAILED.with_debug(str(e))
except CannotLoan as e:
if isinstance(e, NoAvailableCopiesWhenReserved):
result = e.as_problem_detail_document()
else:
result = CHECKOUT_FAILED.with_debug(str(e))
except CannotHold as e:
result = HOLD_FAILED.with_debug(str(e))
except CannotRenew as e:
Expand Down

0 comments on commit 93cf672

Please sign in to comment.