#23002: handle_uncaught_exception: add support for debug=True kwarg / factor
request.error logging out
--------------------------------------+--------------------
     Reporter:  blueyed               |      Owner:  nobody
         Type:  Cleanup/optimization  |     Status:  new
    Component:  Core (Other)          |    Version:  master
     Severity:  Normal                |   Keywords:
 Triage Stage:  Unreviewed            |  Has patch:  0
Easy pickings:  0                     |      UI/UX:  0
--------------------------------------+--------------------
 It would be useful if you could call `handle_uncaught_exception` with
 `debug=True` explicitly (which would default to `settings.DEBUG`).


 Additionally, the he logging part in `handle_uncaught_exception` could be
 moved into a separate function:

 {{{
         logger.error('Internal Server Error: %s', request.path,
             exc_info=exc_info,
             extra={
                 'status_code': 500,
                 'request': request
             }
         )
 }}}
 (Source:
 
https://github.com/django/django/blob/master/django/core/handlers/base.py#L232-238)

 This would make it easier to provide consistent behavior with e.g.
 middlewares that want to provide `technical_500_response` (e.g. "Technical
 500 by group membership",
 https://djangosnippets.org/snippets/1719/#c5852).

 While they could copy the code to call the `logger`, it seems to be better
 having a consistent method that can be called.


 The following code might work just as well, but is more likely to break
 (and changing `settings` in the code should not get done IIRC):

 {{{
 def get_technical_500_response_with_debug():
     from django.conf import settings
     debug_orig = settings.DEBUG
     settings.DEBUG = True
     r = technical_500_response(request, *exc_info)
     settings.DEBUG = debug_orig
     return r
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/23002>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.8228daf0e112638a92e139e35896d1e2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to