From 754e8f214b940e05298cb360ed829f5c685d55a5 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Thu, 25 Jul 2024 11:07:33 -0500 Subject: Rename module: qc_app --> uploader --- qc_app/errors.py | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 qc_app/errors.py (limited to 'qc_app/errors.py') diff --git a/qc_app/errors.py b/qc_app/errors.py deleted file mode 100644 index 3e7c893..0000000 --- a/qc_app/errors.py +++ /dev/null @@ -1,29 +0,0 @@ -"""Application error handling.""" -import traceback -from werkzeug.exceptions import HTTPException - -import MySQLdb as mdb -from flask import Flask, request, render_template, current_app as app - -def handle_general_exception(exc: Exception): - """Handle generic exceptions.""" - trace = traceback.format_exc() - app.logger.error( - "Error (%s.%s): Generic unhandled exception!! (URI: %s)\n%s", - exc.__class__.__module__, exc.__class__.__name__, request.url, trace) - return render_template("unhandled_exception.html", trace=trace), 500 - -def handle_http_exception(exc: HTTPException): - """Handle HTTP exceptions.""" - app.logger.error( - "HTTP Error %s: %s", exc.code, exc.description, exc_info=True) - return render_template("http-error.html", - request_url=request.url, - exc=exc, - trace=traceback.format_exception(exc)), exc.code - -def register_error_handlers(appl: Flask): - """Register top-level error/exception handlers.""" - appl.register_error_handler(Exception, handle_general_exception) - appl.register_error_handler(HTTPException, handle_http_exception) - appl.register_error_handler(mdb.MySQLError, handle_general_exception) -- cgit v1.2.3