Make handle_uncaught_exception() more easily patch-able
|Reported by:||Leonid Grinberg||Owned by:||nobody|
|Severity:||Keywords:||mail, unhandlederror, http500|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
When a 500 error happens that is not handled by any middleware, etc., Django goes into core.handlers.base.handle_uncaught_exception, which, if settings.DEBUG is set to False, generates a simple email that contains the traceback and request data and sends it to the admins specified in settings.py. This behavior is not configurable, and in particular there is no easy way to customize what the contents of the email is. The best one can hope to do is to subclass or monkey-patch BaseHandler.
It would be nice for this function to use a helper method of BaseHandler that takes the same information (request and exc_info) and returns the (subject, message) tuple. Then, applications that would like more detailed error emails can simply replace this function with whatever they want. The attached patch does this.
Change History (4)
comment:1 follow-up: 2 Changed 6 years ago by
|Patch needs improvement:||unset|