def process_exception(self, request, exception):
    if settings.DEBUG or isinstance(exception, Http404):
      return None
    if isinstance(exception, apiproxy_errors.CapabilityDisabledError):
      msg = ('Rietveld: App Engine is undergoing maintenance. '
             'Please try again in a while.')
      status = 503
    elif isinstance(exception, (DeadlineExceededError, MemoryError)):
      msg = ('Rietveld is too hungry at the moment.'
             'Please try again in a while.')
      status = 503
    else:
      msg = 'Unhandled exception.'
      status = 500
    logging.exception('%s: ' % exception.__class__.__name__)
    technical = '%s [%s]' % (exception, exception.__class__.__name__)
    if self._text_requested(request):
      content = '%s\n\n%s\n' % (msg, technical)
      content_type = 'text/plain'
    else:
      tpl = loader.get_template('exception.html')
      ctx = Context({'msg': msg, 'technical': technical})
      content = tpl.render(ctx)
      content_type = 'text/html'
    return HttpResponse(content, status=status, content_type=content_type)
dataset/ETHPy150Open rietveld-codereview/rietveld/codereview/middleware.py/PropagateExceptionMiddleware.process_exception/original