Skip to content

Commit

Permalink
If program crashes, attempt to log exception to stderr and show in me…
Browse files Browse the repository at this point in the history
…ssage box
  • Loading branch information
Pidgeot committed Jun 14, 2020
1 parent 100f6d8 commit 6335cdb
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions launch.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""This file is used to launch the program."""
from __future__ import absolute_import
from __future__ import absolute_import, print_function
import sys, os
from core import lnp
sys.path.insert(0, os.path.dirname(__file__))
#pylint: disable=redefined-builtin
#pylint: disable=redefined-builtin, bare-except
__package__ = ""

lnp.PyLNP()
try:
lnp.PyLNP()
except:
import traceback
message = traceback.format_exception(*sys.exc_info())
#Log exception to stderr if possible
try:
print(message, file=sys.stderr)
except:
pass

# Also show error in Tkinter message box if possible
try:
if sys.version_info[0] == 3: # Alternate import names
# pylint:disable=import-error
import tkinter.messagebox as messagebox
else:
# pylint:disable=import-error
import tkMessageBox as messagebox
messagebox.showerror(message=message)
except:
pass

0 comments on commit 6335cdb

Please sign in to comment.