Pass kwargs to excepthook
This commit is contained in:
parent
5716b7505f
commit
b8b8ce21fa
1 changed files with 12 additions and 11 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue