--
Ticket URL: <https://code.djangoproject.com/ticket/31316>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => invalid
* component: Uncategorized => HTTP handling
Comment:
`handler500` should return `HttpResponseServerError`, when it raises an
exception then it's propagated to the next middleware and a custom handler
is called again. This behavior is a side effect of an incorrect
implementation of a custom `handler500`. It's called only once when
returns `HttpResponseServerError` (as documented).
--
Ticket URL: <https://code.djangoproject.com/ticket/31316#comment:1>
Comment (by David Szotten):
apologies if i was being unclear. i acknowledge that the root cause was a
bug in my 500 handler "(poorly designed)". however, my question was about
how django should behave in the presence of such bugs. bugs are a fact of
life, and for when they happen in regular view code, django provides the
handler500 hook for custom error pages. it doesn't seem unreasonable that
from time to time we also have bugs in our error handlers, and my question
is how we want django to behave then. is the current behaviour of re-
calling the handler500 once for each middleware desired in this case, or
would we be interested in exploring other options? (or, perhaps it's not
ideal but too rare to bother improving)
--
Ticket URL: <https://code.djangoproject.com/ticket/31316#comment:2>
* status: closed => new
* resolution: invalid =>
--
Ticket URL: <https://code.djangoproject.com/ticket/31316#comment:3>
* status: new => closed
* resolution: => wontfix
Comment:
This is made by design (see
[https://github.com/django/django/blob/daaa894960e1b2bce8ee31b7c109be84f598a84e/django/core/handlers/base.py#L140-L149
process_exception_by_middleware()]), exceptions are processed by
middlewares (see
[https://docs.djangoproject.com/en/3.0/topics/http/middleware/#process-
exception #process-exception]), and a default exception handler
(`handler500`) is used when `process_exception()` is not implemented.
That's why your custom (buggy) handler is used by all middlewares. Your
implementation doesn't follow documentation and I don't think there is
anything to change in Django.
--
Ticket URL: <https://code.djangoproject.com/ticket/31316#comment:4>