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
1 changed files with 20 additions and 1 deletions

View File

@ -5,13 +5,32 @@ import sys
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