Catch kodi protocol errors (#67555)

This commit is contained in:
Martin 2022-03-30 21:14:53 +02:00 committed by GitHub
parent ea2c3e3310
commit a9ebeb2876
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -278,14 +278,20 @@ def cmd(func):
"""Wrap all command methods.""" """Wrap all command methods."""
try: try:
await func(obj, *args, **kwargs) await func(obj, *args, **kwargs)
except jsonrpc_base.jsonrpc.TransportError as exc: except (
jsonrpc_base.jsonrpc.TransportError,
jsonrpc_base.jsonrpc.ProtocolError,
) as exc:
# If Kodi is off, we expect calls to fail. # If Kodi is off, we expect calls to fail.
if obj.state == STATE_OFF: if obj.state == STATE_OFF:
log_function = _LOGGER.info log_function = _LOGGER.debug
else: else:
log_function = _LOGGER.error log_function = _LOGGER.error
log_function( log_function(
"Error calling %s on entity %s: %r", func.__name__, obj.entity_id, exc "Error calling %s on entity %s: %r",
func.__name__,
obj.entity_id,
exc,
) )
return wrapper return wrapper