diff --git a/cashu/mint/app.py b/cashu/mint/app.py index 50058f21..fe7737bb 100644 --- a/cashu/mint/app.py +++ b/cashu/mint/app.py @@ -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}")