Pass kwargs to excepthook

This commit is contained in:
shortcutme 2019-03-23 03:33:12 +01:00
parent 5716b7505f
commit b8b8ce21fa
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE

View file

@ -24,7 +24,7 @@ def shutdown(reason="Unknown"):
sys.exit(0) sys.exit(0)
# Store last error, ignore notify, allow manual error logging # Store last error, ignore notify, allow manual error logging
def handleError(*args): def handleError(*args, **kwargs):
global last_error global last_error
if not args: # Manual called if not args: # Manual called
args = sys.exc_info() args = sys.exc_info()
@ -33,22 +33,23 @@ def handleError(*args):
silent = False silent = False
if args[0].__name__ != "Notify": if args[0].__name__ != "Notify":
last_error = args last_error = args
if args[0].__name__ == "KeyboardInterrupt": if args[0].__name__ == "KeyboardInterrupt":
shutdown() shutdown("Keyboard interrupt")
return elif not silent and args[0].__name__ != "Notify":
if not silent and args[0].__name__ != "Notify":
logging.exception("Unhandled exception") logging.exception("Unhandled exception")
if "greenlet.py" not in args[2].tb_frame.f_code.co_filename: # Don't display error twice if "greenlet.py" not in args[2].tb_frame.f_code.co_filename: # Don't display error twice
sys.__excepthook__(*args) sys.__excepthook__(*args, **kwargs)
# Ignore notify errors # Ignore notify errors
def handleErrorNotify(*args): def handleErrorNotify(*args, **kwargs):
if args[0].__name__ == "KeyboardInterrupt": err = args[0]
shutdown() if err.__name__ == "KeyboardInterrupt":
if args[0].__name__ != "Notify": shutdown("Keyboard interrupt")
logging.exception("Unhandled exception") elif err.__name__ != "Notify":
sys.__excepthook__(*args) logging.error("Unhandled exception: %s" % [args])
sys.__excepthook__(*args, **kwargs)
if config.debug: # Keep last error for /Debug if config.debug: # Keep last error for /Debug