Error logging and mutables as function defaults (#930)

* Remove mutable iterables as function defaults
* Improve error reporting and standardise how it's done
This commit is contained in:
Veronica Berglyd Olsen
2021-11-10 00:32:01 +01:00
committed by GitHub
parent 67d2e266fd
commit 00eea24e3f
15 changed files with 88 additions and 65 deletions
+10 -3
View File
@@ -43,7 +43,14 @@ def logException():
"""Log the content of an exception message.
"""
exType, exValue, _ = sys.exc_info()
logger.error("%s: %s", exType.__name__, str(exValue).strip("'"))
logger.error("%s: %s", exType.__name__, str(exValue))
def formatException(exc):
"""Format an exception as a string the same way the default
exception handler does.
"""
return f"{type(exc).__name__}: {str(exc)}"
# =============================================================================================== #
@@ -185,11 +192,11 @@ def exceptionHandler(exType, exValue, exTrace):
except Exception as exc:
logger.critical("Could not close the project before exiting")
logger.critical(str(exc))
logger.critical(formatException(exc))
qApp.exit(1)
except Exception as exc:
logger.critical(str(exc))
logger.critical(formatException(exc))
return