Skip to content

Commit

Permalink
Catch CashuErrors (#442)
Browse files Browse the repository at this point in the history
  • Loading branch information
callebtc authored Feb 18, 2024
1 parent 03c7c61 commit c4e8618
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cashu/mint/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,13 @@ async def catch_exceptions(request: Request, call_next):
except Exception:
err_message = e.args[0] if e.args else "Unknown error"

if isinstance(e, CashuError):
if isinstance(e, CashuError) or isinstance(e.args[0], CashuError):
logger.error(f"CashuError: {err_message}")
code = e.code if isinstance(e, CashuError) else e.args[0].code
# return with cors headers
return JSONResponse(
status_code=status.HTTP_400_BAD_REQUEST,
content={"detail": err_message, "code": e.code},
content={"detail": err_message, "code": code},
headers=CORS_HEADERS,
)
logger.error(f"Exception: {err_message}")
Expand Down

0 comments on commit c4e8618

Please sign in to comment.