Skip to content

Commit 290fda5

Browse files
Update src/openedx_tagging/rest_api/v1/exception_handlers.py
Co-authored-by: Kyle McCormick <kyle@kylemccormick.me>
1 parent dc4bc70 commit 290fda5

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/openedx_tagging/rest_api/v1/exception_handlers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ def _custom_exception_handler(exc: Exception, context: dict) -> Response | None:
3131
if is_expected_exception:
3232
return exception_handler(exc, context)
3333

34-
# Making really sure that any unexpected exception gets logged
35-
log.error(exc, stack_info=True, exc_info=True)
34+
# DRF always calls exception handlers from within an `except:` block, so we can assume
35+
# that `log.exception` will automatically insert those exception details and a stack trace.
36+
log.exception("Unexpected exception while handling API request")
3637

3738
if settings.DEBUG:
3839
description_with_traceback = f"{exc.__class__.__name__}: {str(exc)}\n\nTraceback:\n{traceback.format_exc()}"

0 commit comments

Comments
 (0)