1
0
Fork 0
mirror of https://github.com/borgbase/vorta synced 2024-12-22 07:43:09 +00:00

Improve exception handling. By @samuel-w (#628)

This commit is contained in:
samuel-w 2020-12-15 21:03:24 -06:00 committed by GitHub
parent 7bff91fd21
commit d6f368ae50
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,13 +5,32 @@
import peewee
from vorta._version import __version__
from vorta.config import SETTINGS_DIR
from vorta.log import init_logger
from vorta.log import init_logger, logger
from vorta.models import init_db
from vorta.updater import get_updater
from vorta.utils import parse_args
def main():
def exception_handler(type, value, tb):
from traceback import format_exception
from PyQt5.QtWidgets import QMessageBox
logger.critical("Uncaught exception, file a report at https://github.com/borgbase/vorta/issues/new",
exc_info=(type, value, tb))
full_exception = ''.join(format_exception(type, value, tb))
if app:
QMessageBox.critical(None,
app.tr("Fatal Error"),
app.tr(
"Uncaught exception, please file a report with this text at\n"
"https://github.com/borgbase/vorta/issues/new\n") + full_exception)
else:
# Crashed before app startup, cannot translate
sys.exit(1)
sys.excepthook = exception_handler
app = None
args = parse_args()
signal.signal(signal.SIGINT, signal.SIG_DFL) # catch ctrl-c and exit