Skip to content
Myr

typing_error_handler.py

This file

Path

tests/typing/typing_error_handler.py

33 lines · 647 bytes · Python

Last changed by

Merge branch '2.1.x'David Lordbefore adoption7a2d5fb

History of this file

Take it

1from __future__ import annotations23from http import HTTPStatus45from werkzeug.exceptions import BadRequest6from werkzeug.exceptions import NotFound78from flask import Flask910app = Flask(__name__)111213@app.errorhandler(400)14@app.errorhandler(HTTPStatus.BAD_REQUEST)15@app.errorhandler(BadRequest)16def handle_400(e: BadRequest) -> str:17    return ""181920@app.errorhandler(ValueError)21def handle_custom(e: ValueError) -> str:22    return ""232425@app.errorhandler(ValueError)26def handle_accept_base(e: Exception) -> str:27    return ""282930@app.errorhandler(BadRequest)31@app.errorhandler(404)32def handle_multiple(e: BadRequest | NotFound) -> str:33    return ""