2022-06-06 21:30:30 +02:00
|
|
|
import json
|
2022-05-19 18:15:11 +02:00
|
|
|
|
2022-06-06 21:30:30 +02:00
|
|
|
from apiflask import APIFlask
|
2023-01-14 01:37:31 +01:00
|
|
|
from werkzeug.exceptions import HTTPException
|
2022-06-06 21:30:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
def register_error_handlers(app: APIFlask):
|
|
|
|
@app.errorhandler(HTTPException)
|
|
|
|
def handle_http_exception(e):
|
|
|
|
response = e.get_response()
|
2023-01-14 17:38:03 +01:00
|
|
|
response.data = json.dumps({"error": e.description})
|
|
|
|
response.content_type = "application/json"
|
2022-06-06 21:30:30 +02:00
|
|
|
return response
|