aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-11-30 10:44:15 +0300
committerFrederick Muriuki Muriithi2023-11-30 10:44:15 +0300
commit392a42ada60670f4f8212da746e25889f0ed2299 (patch)
tree1c0211b95c728d2f9a1988f832211f022b327345
parent9d167a5fa97480d813b16fd1420349af2008071f (diff)
downloadgn-uploader-392a42ada60670f4f8212da746e25889f0ed2299.tar.gz
Error logging: Add more details to help with debugging.
-rw-r--r--qc_app/errors.py16
1 files changed, 6 insertions, 10 deletions
diff --git a/qc_app/errors.py b/qc_app/errors.py
index 06c5dd4..7af7696 100644
--- a/qc_app/errors.py
+++ b/qc_app/errors.py
@@ -3,21 +3,17 @@ import logging
import traceback
import MySQLdb as mdb
-from flask import Flask, render_template
+from flask import Flask, request, 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):
- """Handle MySQLdb errors."""
- trace = traceback.format_exc()
- logging.error("MySQLError: Generic MySQL Error!!\n%s", trace)
+ logging.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)
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_mysqldb_errors)
+ app.register_error_handler(mdb.MySQLError, handle_general_exception)