Skip to content

Commit

Permalink
Add unexpected error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
gideonshaked committed Jul 25, 2021
1 parent 05fb3b1 commit 40bec50
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/client/client/gui.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import tkinter as tk
import traceback
from pathlib import Path

import appdirs
Expand All @@ -12,6 +13,7 @@
class MainApplication:
def __init__(self, master: tk.Tk):
self.master = master
self.master.report_callback_exception = self.report_callback_exception
self.frame = tk.Frame(master)
self.master.title("PALMS v0.6.0")
self.master.geometry("")
Expand Down Expand Up @@ -130,6 +132,13 @@ def verify_positions(positions: dict) -> bool:
def change_position_scale(positions: dict) -> dict:
return {key: val + 45 if key == "a" else val + 25 for key, val in positions.items()}

def report_callback_exception(self, *args):
DialogBox(
tk.Toplevel(self.master),
"Error",
f"An unexpected error has occurred.\nTraceback:\n\n{''.join(traceback.format_exception(*args))}",
)


class Settings:
def __init__(self):
Expand Down

0 comments on commit 40bec50

Please sign in to comment.