flask-webhook/flask_demo_api/error_handlers.py

15 lines
316 B
Python
Raw Permalink Normal View History

2024-04-22 04:00:23 +03:00
from flask import Flask, jsonify
def name_not_found_error(e):
return jsonify(error=str(e)), 404
def bad_request_error(e):
return jsonify(error=str(e)), 400
def register_errors(app: Flask):
app.register_error_handler(404, name_not_found_error)
app.register_error_handler(400, bad_request_error)