Skip to content

Instantly share code, notes, and snippets.

@matthewdeanmartin
Created February 2, 2015 20:00
Show Gist options
  • Save matthewdeanmartin/173c380cb7522ca0d6b8 to your computer and use it in GitHub Desktop.
Save matthewdeanmartin/173c380cb7522ca0d6b8 to your computer and use it in GitHub Desktop.
Add this and I find out the app is constantly throwing errors that were previously hidden.
import sys
import traceback
# https://stackoverflow.com/questions/6666882/tkinter-python-catching-exceptions
# https://stackoverflow.com/questions/739654/how-can-i-make-a-chain-of-function-decorators-in-python
# https://stackoverflow.com/questions/1415812/why-use-kwargs-in-python-what-are-some-real-world-advantages-over-using-named
def handle_tk_errors(method_to_decorate):
def wrapper(*args, **kwargs):
try:
return method_to_decorate(*args, **kwargs)
except Exception as ex:
traceback.print_exc()
print("Error: %s" % ex)
sys.exit(1)
return wrapper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment