Skip to content

Commit

Permalink
Fix logging middleware exception handling
Browse files Browse the repository at this point in the history
Signed-off-by: jamshale <[email protected]>
  • Loading branch information
jamshale committed Sep 19, 2023
1 parent 243f8de commit 8176c56
Show file tree
Hide file tree
Showing 6 changed files with 600 additions and 14 deletions.
11 changes: 10 additions & 1 deletion oidc-controller/api/core/logger_util.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import structlog
import time
from typing import Callable, Any

logger = structlog.getLogger(__name__)

from typing import Callable, Any


def log_debug(func: Callable[..., Any]) -> Callable[..., Any]:
Expand All @@ -20,3 +21,11 @@ def wrapper(*args, **kwargs):
return ret_val

return wrapper


def extract_error_msg_from_traceback_exc(format_exc) -> str:
try:
return format_exc.splitlines()[-1].split(": ")[1:][0]
except Exception:
logger.error(f"Failed to extract error message from traceback: {format_exc}")
return "Unknown error"
Loading

0 comments on commit 8176c56

Please sign in to comment.