http: Make sure to decode exceptions for logging
This commit is contained in:
parent
0fb6c620df
commit
6c5970ffc3
@ -10,7 +10,7 @@ import tornado.websocket
|
|||||||
|
|
||||||
import mopidy
|
import mopidy
|
||||||
from mopidy import core, models
|
from mopidy import core, models
|
||||||
from mopidy.utils import jsonrpc
|
from mopidy.utils import encoding, jsonrpc
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -81,8 +81,9 @@ class WebSocketHandler(tornado.websocket.WebSocketHandler):
|
|||||||
try:
|
try:
|
||||||
client.write_message(msg)
|
client.write_message(msg)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
error_msg = encoding.locale_decode(e)
|
||||||
logger.debug('Broadcast of WebSocket message to %s failed: %s',
|
logger.debug('Broadcast of WebSocket message to %s failed: %s',
|
||||||
client.request.remote_ip, e)
|
client.request.remote_ip, error_msg)
|
||||||
# TODO: should this do the same cleanup as the on_message code?
|
# TODO: should this do the same cleanup as the on_message code?
|
||||||
|
|
||||||
def initialize(self, core):
|
def initialize(self, core):
|
||||||
@ -121,7 +122,8 @@ class WebSocketHandler(tornado.websocket.WebSocketHandler):
|
|||||||
'Sent WebSocket message to %s: %r',
|
'Sent WebSocket message to %s: %r',
|
||||||
self.request.remote_ip, response)
|
self.request.remote_ip, response)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error('WebSocket request error: %s', e)
|
error_msg = encoding.locale_decode(e)
|
||||||
|
logger.error('WebSocket request error: %s', error_msg)
|
||||||
if self.ws_connection:
|
if self.ws_connection:
|
||||||
# Tornado 3.2+ checks if self.ws_connection is None before
|
# Tornado 3.2+ checks if self.ws_connection is None before
|
||||||
# using it, but not older versions.
|
# using it, but not older versions.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user