def _handle_exception(cls, exception): # in case of Exception, e.g. 404, we don't step into _dispatch cls._handle_debug() # If handle_exception returns something different than None, it will be used as a response # This is done first as the attachment path may # not match any HTTP controller if isinstance( exception, werkzeug.exceptions.HTTPException) and exception.code == 404: serve = cls._serve_fallback(exception) if serve: return serve # Don't handle exception but use werkzeug debugger if server in --dev mode # Don't intercept JSON request to respect the JSON Spec and return exception as JSON # "The Response is expressed as a single JSON Object, with the following members: # jsonrpc, result, error, id" if ('werkzeug' in tools.config['dev_mode'] and not isinstance(exception, werkzeug.exceptions.NotFound) and request._request_type != 'json'): raise exception try: return request._handle_exception(exception) except AccessDenied: return werkzeug.exceptions.Forbidden()
def _handle_exception(cls, exception): # If handle_exception returns something different than None, it will be used as a response # This is done first as the attachment path may # not match any HTTP controller if isinstance(exception, werkzeug.exceptions.HTTPException) and exception.code == 404: serve = cls._serve_fallback(exception) if serve: return serve # Don't handle exception but use werkeug debugger if server in --dev mode if 'werkzeug' in tools.config['dev_mode']: raise try: return request._handle_exception(exception) except AccessDenied: return werkzeug.exceptions.Forbidden()
def _handle_exception(self, exception): # If handle_exception returns something different than None, it will be used as a response # This is done first as the attachment path may # not match any HTTP controller if isinstance(exception, werkzeug.exceptions.HTTPException) and exception.code == 404: attach = self._serve_attachment() if attach: return attach # Don't handle exception but use werkeug debugger if server in --dev mode if 'werkzeug' in tools.config['dev_mode']: raise try: return request._handle_exception(exception) except AccessDenied: return werkzeug.exceptions.Forbidden()
def _handle_exception(cls, exception): # in case of Exception, e.g. 404, we don't step into _dispatch cls._handle_debug() # If handle_exception returns something different than None, it will be used as a response # This is done first as the attachment path may # not match any HTTP controller if isinstance(exception, werkzeug.exceptions.HTTPException) and exception.code == 404: serve = cls._serve_fallback(exception) if serve: return serve # Don't handle exception but use werkzeug debugger if server in --dev mode if 'werkzeug' in tools.config['dev_mode'] and not isinstance(exception, werkzeug.exceptions.NotFound): raise exception try: return request._handle_exception(exception) except AccessDenied: return werkzeug.exceptions.Forbidden()