From 061a40c14f3adf39c794aa0ddace4835f9282e9b Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Wed, 10 Apr 2024 08:34:01 +0300 Subject: Gracefully handle all `werkzeug.exceptions` errors. --- qc_app/errors.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'qc_app') diff --git a/qc_app/errors.py b/qc_app/errors.py index d7d3858..ff656b8 100644 --- a/qc_app/errors.py +++ b/qc_app/errors.py @@ -1,6 +1,7 @@ """Application error handling.""" import logging import traceback +from werkzeug.exceptions import HTTPException import MySQLdb as mdb from flask import Flask, request, render_template, current_app as app @@ -16,4 +17,5 @@ def handle_general_exception(exc: Exception): def register_error_handlers(app: Flask): """Register top-level error/exception handlers.""" app.register_error_handler(Exception, handle_general_exception) + app.register_error_handler(HTTPException, handle_general_exception) app.register_error_handler(mdb.MySQLError, handle_general_exception) -- cgit v1.2.3