fix: suppress only baton error #102
@@ -36,6 +36,7 @@ from aarecommon.errors.exception_handler import (
|
||||
AareUserError,
|
||||
AuthenticationException,
|
||||
AutomationError,
|
||||
UserRightsException,
|
||||
)
|
||||
from fastapi import HTTPException
|
||||
from fastapi import status as api_status
|
||||
@@ -171,6 +172,12 @@ def register_exception_handlers(app) -> None:
|
||||
else api_status.HTTP_403_FORBIDDEN
|
||||
)
|
||||
body = _error_body(exc, code_override=code_override)
|
||||
# TODO: migrate baton to its own error type
|
||||
if isinstance(exc, UserRightsException):
|
||||
if "do not hold the baton" in exc.message:
|
||||
return JSONResponse(
|
||||
status_code=status, content=body, headers=getattr(exc, "headers", None)
|
||||
)
|
||||
logger.warning(
|
||||
"AareAuthError: %s",
|
||||
body["message"],
|
||||
|
||||
Reference in New Issue
Block a user