From 3b725c7354b185cc748f1d8ebfac6bab5e17b4aa Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Thu, 30 Nov 2023 09:58:23 +0300 Subject: Fix errors caught by pylint and mypy. --- qc_app/errors.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'qc_app') diff --git a/qc_app/errors.py b/qc_app/errors.py index 902e7e0..06c5dd4 100644 --- a/qc_app/errors.py +++ b/qc_app/errors.py @@ -5,12 +5,14 @@ import traceback import MySQLdb as mdb from flask import Flask, render_template -def handle_general_exception(exc: Exception): +def handle_general_exception(_exc: Exception): + """Handle generic exceptions.""" trace = traceback.format_exc() logging.error("Error: Generic unhandled exception!!\n%s", trace) return render_template("unhandled_exception.html", trace=trace) -def handle_general_MySQLdb_errors(exc: mdb.MySQLError): +def handle_general_mysqldb_errors(_exc: mdb.MySQLError): + """Handle MySQLdb errors.""" trace = traceback.format_exc() logging.error("MySQLError: Generic MySQL Error!!\n%s", trace) return render_template("unhandled_exception.html", trace=trace) @@ -18,4 +20,4 @@ def handle_general_MySQLdb_errors(exc: mdb.MySQLError): def register_error_handlers(app: Flask): """Register top-level error/exception handlers.""" app.register_error_handler(Exception, handle_general_exception) - app.register_error_handler(mdb.MySQLError, handle_general_exception) + app.register_error_handler(mdb.MySQLError, handle_general_mysqldb_errors) -- cgit v1.2.3