Skip to content

Commit

Permalink
Log unexpected exceptions in exception view
Browse files Browse the repository at this point in the history
A few of these don't produce any logging in local development making
debugging them tricky.

Added an explicit logging here. Not sure if this would duplicate logging
in a production environment. If that the case we can change this from
`exception` to `debug`.
marcospri committed Nov 13, 2023
1 parent 45938d9 commit 8092027
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lms/views/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import logging

from pyramid import i18n
from pyramid.config import not_
from pyramid.httpexceptions import HTTPClientError
@@ -14,6 +16,8 @@

_ = i18n.TranslationStringFactory(__package__)

LOG = logging.getLogger(__name__)


@view_defaults(path_info=not_("^/api/.*"), renderer="lms:templates/error.html.jinja2")
class ExceptionViews:
@@ -94,6 +98,7 @@ def serializable_error(self):

@exception_view_config(context=Exception)
def error(self):
LOG.exception("Unexpected error %s", type(self.exception))
return self.error_response(
500,
_(

0 comments on commit 8092027

Please sign in to comment.