Skip to content

Commit af55604

Browse files
committed
Improve error popup layout
1 parent 2ae26dd commit af55604

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

main.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import traceback
1+
import sys
2+
from traceback import TracebackException
23

34
import PySimpleGUI as sg
45

@@ -10,9 +11,17 @@
1011
gui.init_settings()
1112
gui.run_window()
1213
except Exception as e:
14+
error = sys.exc_info()[1]
15+
stack = sys.exc_info()[2]
16+
17+
te = TracebackException(type(error), error, stack, limit=None, compact=True)
18+
stack_str = "".join(te.stack.format())
19+
1320
sg.popup_error(
14-
"AN EXCEPTION OCCURRED!\n\nYou should make a screenshot of this and either make a GitHub issue for this by clicking the GitHub icon in this program, or you can send it to MyNameIsTrez#1585 on Discord.\n"
15-
+ "_" * 60,
16-
traceback.format_exc(),
21+
error.args[0] + "_" * 60 + "\n",
22+
"If you can't figure out how to fix the above error, you should make a screenshot of this entire window (using Windows key + Shift + S), and either make a GitHub issue for this by clicking the GitHub icon in this program, or you can send this to MyNameIsTrez#1585 on Discord.\n"
23+
+ "_" * 60
24+
+ "\n",
25+
stack_str,
1726
title="AN EXCEPTION OCCURRED!",
1827
)

0 commit comments

Comments
 (0)