Skip to content

Commit

Permalink
request.body access
Browse files Browse the repository at this point in the history
  • Loading branch information
phact committed Aug 21, 2024
1 parent d6a1c08 commit fc5f65f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions impl/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ async def shutdown_event():
@app.exception_handler(Exception)
async def generic_exception_handler(request: Request, exc: Exception):
# Log the error
logger.error(f"Unexpected error: {exc} for request url {request.url} request method {request.method} request path params {request.path_params} request query params {request.query_params} request body {await request.body()} base_url {request.base_url}")
logger.error(f"Unexpected error: {exc} for request url {request.url} request method {request.method} request path params {request.path_params} request query params {request.query_params} base_url {request.base_url}")

if isinstance(exc, HTTPException):
raise exec
Expand All @@ -247,7 +247,7 @@ async def generic_exception_handler(request: Request, exc: Exception):
async def validation_exception_handler(request: Request, exc: RequestValidationError):
logging.error(f"Validation error for request: {request.url}")
logging.error(f"Body: {exc.body}")
logger.error(f"Validation error: {exc} for request url {request.url} request method {request.method} request path params {request.path_params} request query params {request.query_params} request body {await request.body()} base_url {request.base_url}")
logger.error(f"Validation error: {exc} for request url {request.url} request method {request.method} request path params {request.path_params} request query params {request.query_params} base_url {request.base_url}")
logging.error(f"Errors: {exc.errors()}")
return JSONResponse(
status_code=422,
Expand Down

0 comments on commit fc5f65f

Please sign in to comment.