Log exceptions that happen during service call (#11394)

* Log exceptions that happen during service call

* Lint
This commit is contained in:
Paulus Schoutsen 2018-01-01 15:32:39 -08:00 committed by GitHub
parent cb899a9465
commit 1b4be0460c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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):