fix exception handling
This commit is contained in:
parent
d63ec84745
commit
7a1dab3319
10
sanic/app.py
10
sanic/app.py
|
@ -577,13 +577,17 @@ class Sanic:
|
||||||
if isawaitable(response):
|
if isawaitable(response):
|
||||||
response = await response
|
response = await response
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if self.debug:
|
if isinstance(e, SanicException):
|
||||||
|
response = self.error_handler.default(request=request,
|
||||||
|
exception=e)
|
||||||
|
elif self.debug:
|
||||||
response = HTTPResponse(
|
response = HTTPResponse(
|
||||||
"Error while handling error: {}\nStack: {}".format(
|
"Error while handling error: {}\nStack: {}".format(
|
||||||
e, format_exc()))
|
e, format_exc()), status=500)
|
||||||
else:
|
else:
|
||||||
response = HTTPResponse(
|
response = HTTPResponse(
|
||||||
"An error occurred while handling an error")
|
"An error occurred while handling an error",
|
||||||
|
status=500)
|
||||||
finally:
|
finally:
|
||||||
# -------------------------------------------- #
|
# -------------------------------------------- #
|
||||||
# Response Middleware
|
# Response Middleware
|
||||||
|
|
Loading…
Reference in New Issue
Block a user