aboutsummaryrefslogtreecommitdiff
path: root/qc_app
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-11-28 16:51:31 +0300
committerFrederick Muriuki Muriithi2023-11-28 16:51:31 +0300
commitc26b9acc8d51bb5efe4e50114a6c723552e27a5f (patch)
tree13e4b9e6f94951ce3ca58136804854a34d2748cd /qc_app
parentc1dcd4f20e3e0e89d7e2dce051526d2db36f9579 (diff)
downloadgn-uploader-c26b9acc8d51bb5efe4e50114a6c723552e27a5f.tar.gz
Handle generic MySQL errors at the top-level.
Diffstat (limited to 'qc_app')
-rw-r--r--qc_app/errors.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/qc_app/errors.py b/qc_app/errors.py
index 0da6b3c..902e7e0 100644
--- a/qc_app/errors.py
+++ b/qc_app/errors.py
@@ -2,6 +2,7 @@
import logging
import traceback
+import MySQLdb as mdb
from flask import Flask, render_template
def handle_general_exception(exc: Exception):
@@ -9,6 +10,12 @@ def handle_general_exception(exc: Exception):
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):
+ trace = traceback.format_exc()
+ logging.error("MySQLError: Generic MySQL Error!!\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)
+ app.register_error_handler(mdb.MySQLError, handle_general_exception)