Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better logs with the full exception via QgsMessageLog #83

Merged
merged 1 commit into from
Apr 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion open_alaqs/core/alaqsutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import os
import sys

from qgis.core import Qgis, QgsMessageLog
from qgis.utils import spatialite_connect

from open_alaqs.core import alaqsdblite
Expand All @@ -35,16 +36,26 @@ def print_error(function_name, exception_object, e_object, log=logger):
print(exception_object, e_object)
except Exception:
pass

exc_type, exc_obj, exc_tb = sys.exc_info()
error = "[-] Error in %s() [line %d]: %s" % (
error = "[-] Error in %s() [line %d]: %s %s" % (
function_name,
exc_tb.tb_lineno,
exc_type,
exc_obj,
)

if "object has been deleted" in str(exc_obj):
return None
else:
log.error(error)

QgsMessageLog.logMessage(
f"{str(e_object)}:\n{exc_tb}",
tag="Open ALAQS",
level=Qgis.MessageLevel.Critical,
)

return error


Expand Down
Loading