From 3f7a1c47a0bd0e0359c1e885f77b09f77c7a9a54 Mon Sep 17 00:00:00 2001 From: mhdzumair Date: Sun, 17 Nov 2024 18:51:27 +0530 Subject: [PATCH] Improve error logging and response for request processing --- mediaflow_proxy/utils/crypto_utils.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mediaflow_proxy/utils/crypto_utils.py b/mediaflow_proxy/utils/crypto_utils.py index 10e686a..1e5bb40 100644 --- a/mediaflow_proxy/utils/crypto_utils.py +++ b/mediaflow_proxy/utils/crypto_utils.py @@ -2,6 +2,7 @@ import base64 import json import logging import time +import traceback from urllib.parse import urlencode from Crypto.Cipher import AES @@ -78,9 +79,13 @@ class EncryptionMiddleware(BaseHTTPMiddleware): 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