Skip to content

Commit

Permalink
Improve error logging and response for request processing
Browse files Browse the repository at this point in the history
  • Loading branch information
mhdzumair committed Nov 17, 2024
1 parent a3dbfd7 commit 3f7a1c4
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions mediaflow_proxy/utils/crypto_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import json
import logging
import time
import traceback
from urllib.parse import urlencode

from Crypto.Cipher import AES
Expand Down Expand Up @@ -78,9 +79,13 @@ async def dispatch(self, request: Request, call_next):

try:
response = await call_next(request)
except Exception as e:
logging.exception("An error occurred while processing the request")
return JSONResponse(content={"error": str(e)}, status_code=500)
except Exception:
exc = traceback.format_exc(chain=False)
logging.error("An error occurred while processing the request, error: %s", exc)
return JSONResponse(
content={"error": "An error occurred while processing the request, check the server for logs"},
status_code=500,
)
return response

@staticmethod
Expand Down

0 comments on commit 3f7a1c4

Please sign in to comment.