Exemplo n.º 1
0
def technical_500_response(request, exc_type, exc_value, tb, status_code=500):
    """
    Create a technical server error response. The last three arguments are
    the values returned from sys.exc_info() and friends.
    """
    reporter = ExceptionReporter(request, exc_type, exc_value, tb)
    html = reporter.get_traceback_html()
    response = internal_error()
    if settings.DEBUG:
        response.write(html)
    else:
        mail_admins('INTERNAL SERVER ERROR', html)
    return response
Exemplo n.º 2
0
def technical_500_response(request, exc_type, exc_value, tb, status_code=500):
    """
    Create a technical server error response. The last three arguments are
    the values returned from sys.exc_info() and friends.
    """
    reporter = ExceptionReporter(request, exc_type, exc_value, tb)
    html = reporter.get_traceback_html()
    response = internal_error()
    if settings.DEBUG:
        response.write(html)
    else:
        mail_admins('INTERNAL SERVER ERROR', html)
    return response
Exemplo n.º 3
0
 def __call__(self, request, following):
     assert following is not None
     try:
         response = following(request)
         if response is None:
             response = not_found()
     except (KeyboardInterrupt, SystemExit, MemoryError):
         raise
     except Exception:
         exc_info = sys.exc_info()
         extra = self.extra_provider and self.extra_provider(request) or {}
         self.logger.error(
             ''.join(format_exception_only(*exc_info[:2])).strip('\n'),
             exc_info=exc_info,
             extra=extra)
         response = internal_error()
     status_code = response.status_code
     if status_code >= 400:
         error_route_name = self.error_mapping[status_code]
         route_name = request.environ['route_args'].get('route_name')
         if error_route_name != route_name:
             response = RedirectRouteHandler(request, error_route_name)
     return response