compat: honor DEBUG_PROPAGATE_EXCEPTIONS in Django compatibility views (#73489)

This commit is contained in:
Benjamin Dauvergne 2023-01-17 10:54:24 +01:00 committed by Gitea
parent 7d04a96a07
commit 77ac56cf2f
1 changed files with 8 additions and 0 deletions

View File

@ -74,6 +74,10 @@ class TemplateWithFallbackView(TemplateView):
context = {'body': get_publisher().finish_interrupted_request(exc)}
self.quixote_response = get_request().response
except Exception:
# Follow native django DEBUG_PROPAGATE_EXCEPTIONS setting, re-raise exception
# so it can be caught/stopped at when running tests.
if settings.DEBUG_PROPAGATE_EXCEPTIONS:
raise
context = {'body': get_publisher().finish_failed_request()}
self.quixote_response = get_request().response
@ -215,6 +219,10 @@ class CompatWcsPublisher(WcsPublisher):
except PublishError as exc:
output = self.finish_interrupted_request(exc)
except Exception:
# Follow native django DEBUG_PROPAGATE_EXCEPTIONS setting, re-raise exception
# so it can be caught/stopped at when running tests.
if settings.DEBUG_PROPAGATE_EXCEPTIONS:
raise
output = self.finish_failed_request()
response = request.response