def handle_exception(request, exception, template_name): # XXX: remove this? exceptions are already displayed in debug mode tb = traceback.format_exc() print(tb, file=sys.stderr) if settings.DEBUG: return None log_exception(request, exception, tb) msg = force_text(exception) if request.is_ajax(): return JsonResponseServerError({'msg': msg}) ctx = { 'exception': msg, } if hasattr(exception, 'filename'): msg_args = { 'filename': exception.filename, 'errormsg': exception.strerror, } msg = _( 'Error accessing %(filename)s, Filesystem ' 'sent error: %(errormsg)s', msg_args) ctx['fserror'] = msg return HttpResponseServerError( render_to_string(template_name, context=ctx, request=request))
def handle_exception(request, exception, template_name): # XXX: remove this? exceptions are already displayed in debug mode tb = traceback.format_exc() print >> sys.stderr, tb if settings.DEBUG: return None try: log_exception(request, exception, tb) msg = force_unicode(exception) if request.is_ajax(): return JsonResponseServerError({'msg': msg}) ctx = { 'exception': msg, } if hasattr(exception, 'filename'): msg_args = { 'filename': exception.filename, 'errormsg': exception.strerror, } msg = _( 'Error accessing %(filename)s, Filesystem ' 'sent error: %(errormsg)s', msg_args) ctx['fserror'] = msg return HttpResponseServerError( render_to_string(template_name, ctx, RequestContext(request))) except: # Let's not confuse things by throwing an exception here pass
def handle_exception(request, exception, template_name): # XXX: remove this? exceptions are already displayed in debug mode tb = traceback.format_exc() print(tb, file=sys.stderr) if settings.DEBUG: return None try: log_exception(request, exception, tb) msg = force_str(exception) if request.is_ajax(): return JsonResponseServerError({"msg": msg}) ctx = { "exception": msg, } if hasattr(exception, "filename"): msg_args = { "filename": exception.filename, "errormsg": exception.strerror, } msg = _("Error accessing %(filename)s, Filesystem " "sent error: %(errormsg)s" % msg_args) ctx["fserror"] = msg return HttpResponseServerError( render_to_string(template_name, context=ctx, request=request)) except: # Let's not confuse things by throwing an exception here pass