|
5 | 5 | # List of valid templates is explicitly managed for (short-term)
|
6 | 6 | # security reasons.
|
7 | 7 |
|
8 |
| - |
| 8 | +import logging |
9 | 9 | import mimetypes
|
10 | 10 |
|
11 | 11 | from django.conf import settings
|
|
23 | 23 | from common.djangoapps.util.views import fix_crum_request
|
24 | 24 | from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
|
25 | 25 |
|
| 26 | +log = logging.getLogger(__name__) |
| 27 | + |
26 | 28 | valid_templates = []
|
27 | 29 |
|
28 | 30 | if settings.STATIC_GRAB:
|
@@ -122,4 +124,21 @@ def render_429(request, exception=None): # lint-amnesty, pylint: disable=unused
|
122 | 124 |
|
123 | 125 | @fix_crum_request
|
124 | 126 | def render_500(request):
|
125 |
| - return HttpResponseServerError(render_to_string('static_templates/server-error.html', {}, request=request)) |
| 127 | + """ |
| 128 | + Render the generic error page when we have an uncaught error. |
| 129 | + """ |
| 130 | + try: |
| 131 | + return HttpResponseServerError(render_to_string('static_templates/server-error.html', {}, request=request)) |
| 132 | + except BaseException as e: |
| 133 | + # If we can't render the error page, ensure we don't raise another |
| 134 | + # exception -- because if we do, we'll probably just end up back |
| 135 | + # at the same rendering error. |
| 136 | + # |
| 137 | + # This is an attempt at working around the recursive error handling issues |
| 138 | + # observed in <https://github.com/openedx/edx-platform/issues/35151>, which |
| 139 | + # were triggered by Mako and translation errors. |
| 140 | + |
| 141 | + log.error("Encountered error while rendering error page.", exc_info=True) |
| 142 | + # This message is intentionally hardcoded and does not involve |
| 143 | + # any translation, templating, etc. Do not translate. |
| 144 | + return HttpResponseServerError("Encountered error while rendering error page.") |
0 commit comments