Skip to content

Commit 21d56d7

Browse files
committed
modified: exception_handler.py to make a more precise error handling
1 parent 58cbdfa commit 21d56d7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import json
2+
from werkzeug.exceptions import HTTPException
3+
4+
5+
def exception_handler(error: Exception) -> json:
6+
code = 500
7+
if isinstance(error, HTTPException):
8+
code = error.code
9+
return json.dumps({'error': error.__repr__()}), code

0 commit comments

Comments
 (0)