mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 08:17:08 +00:00
Log exceptions that happen during service call (#11394)
* Log exceptions that happen during service call * Lint
This commit is contained in:
parent
cb899a9465
commit
1b4be0460c
@ -1024,19 +1024,22 @@ class ServiceRegistry(object):
|
||||
|
||||
service_call = ServiceCall(domain, service, service_data, call_id)
|
||||
|
||||
if service_handler.is_callback:
|
||||
service_handler.func(service_call)
|
||||
fire_service_executed()
|
||||
elif service_handler.is_coroutinefunction:
|
||||
yield from service_handler.func(service_call)
|
||||
fire_service_executed()
|
||||
else:
|
||||
def execute_service():
|
||||
"""Execute a service and fires a SERVICE_EXECUTED event."""
|
||||
try:
|
||||
if service_handler.is_callback:
|
||||
service_handler.func(service_call)
|
||||
fire_service_executed()
|
||||
elif service_handler.is_coroutinefunction:
|
||||
yield from service_handler.func(service_call)
|
||||
fire_service_executed()
|
||||
else:
|
||||
def execute_service():
|
||||
"""Execute a service and fires a SERVICE_EXECUTED event."""
|
||||
service_handler.func(service_call)
|
||||
fire_service_executed()
|
||||
|
||||
self._hass.async_add_job(execute_service)
|
||||
yield from self._hass.async_add_job(execute_service)
|
||||
except Exception: # pylint: disable=broad-except
|
||||
_LOGGER.exception('Error executing service %s', service_call)
|
||||
|
||||
|
||||
class Config(object):
|
||||
|
Loading…
x
Reference in New Issue
Block a user