Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return a response from middleware instead of exception #345

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions oidc-controller/api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
from fastapi import FastAPI
from starlette.requests import Request
from starlette.responses import Response
from fastapi.exceptions import HTTPException
from fastapi.middleware.cors import CORSMiddleware
from fastapi import status as http_status
from fastapi.responses import JSONResponse

from .clientConfigurations.router import router as client_config_router
from .db.session import get_db, init_db
Expand All @@ -21,7 +21,6 @@
from .clientConfigurations.router import router as client_config_router
from .db.session import init_db, get_db
from .routers.socketio import sio_app
from api.core.models import GenericErrorMessage
from api.core.oidc.provider import init_provider

logger: structlog.typing.FilteringBoundLogger = structlog.getLogger(__name__)
Expand Down Expand Up @@ -103,9 +102,13 @@ async def logging_middleware(request: Request, call_next) -> Response:
if os.environ.get("LOG_WITH_JSON", True) is True:
logger.error(traceback.format_exc())

raise HTTPException(
return JSONResponse(
status_code=http_status.HTTP_500_INTERNAL_SERVER_ERROR,
detail="Internal Server Error",
content={
"status": "error",
"message": "Internal Server Error",
"process_time": process_time,
},
)


Expand Down