"""Application error handling.""" import logging import traceback from flask import Flask, render_template def handle_general_exception(exc: Exception): trace = traceback.format_exc() logging.error("Error: Generic unhandled exception!!\n%s", trace) return render_template("unhandled_exception.html", trace=trace) def register_error_handlers(app: Flask): """Register top-level error/exception handlers.""" app.register_error_handler(Exception, handle_general_exception)