Fix error reporting on asnyc websocket functions

This commit is contained in:
shortcutme 2017-02-09 01:53:02 +01:00
parent eb30eb90d6
commit 90c9adc8dc
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE

View file

@ -159,8 +159,17 @@ class UiWebsocket(object):
return permissions return permissions
def asyncWrapper(self, func): def asyncWrapper(self, func):
def asyncErrorWatcher(func, *args, **kwargs):
try:
func(*args, **kwargs)
except Exception, err:
if config.debug: # Allow websocket errors to appear on /Debug
sys.modules["main"].DebugHook.handleError()
self.log.error("WebSocket handleRequest error: %s" % Debug.formatException(err))
self.cmd("error", "Internal error: %s" % Debug.formatException(err, "html"))
def wrapper(*args, **kwargs): def wrapper(*args, **kwargs):
gevent.spawn(func, *args, **kwargs) gevent.spawn(asyncErrorWatcher, func, *args, **kwargs)
return wrapper return wrapper
# Handle incoming messages # Handle incoming messages