Update main.py
Browse files
main.py
CHANGED
|
@@ -105,6 +105,16 @@ def _log_response(resp):
|
|
| 105 |
resp.headers["X-Request-Id"] = getattr(g, "request_id", "-")
|
| 106 |
return resp
|
| 107 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
@app.errorhandler(Exception)
|
| 109 |
def _unhandled_exception(err):
|
| 110 |
logger.exception(
|
|
|
|
| 105 |
resp.headers["X-Request-Id"] = getattr(g, "request_id", "-")
|
| 106 |
return resp
|
| 107 |
|
| 108 |
+
|
| 109 |
+
from werkzeug.exceptions import HTTPException
|
| 110 |
+
|
| 111 |
+
@app.errorhandler(HTTPException)
|
| 112 |
+
def handle_http_exception(err):
|
| 113 |
+
return jsonify({
|
| 114 |
+
"status": "error",
|
| 115 |
+
"message": err.description,
|
| 116 |
+
}), err.code
|
| 117 |
+
|
| 118 |
@app.errorhandler(Exception)
|
| 119 |
def _unhandled_exception(err):
|
| 120 |
logger.exception(
|