1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 04:50:05 +00:00

Improve cloud error handling (#20729)

* Improve cloud error handling

* Lint
This commit is contained in:
Paulus Schoutsen
2019-02-04 01:14:30 -08:00
committed by Pascal Vizeli
parent a3c8439ce2
commit 07b5b68a51
2 changed files with 18 additions and 3 deletions

View File

@@ -107,13 +107,16 @@ def _handle_cloud_errors(handler):
result = await handler(view, request, *args, **kwargs)
return result
except (auth_api.CloudError, asyncio.TimeoutError) as err:
except Exception as err: # pylint: disable=broad-except
err_info = _CLOUD_ERRORS.get(err.__class__)
if err_info is None:
_LOGGER.exception(
"Unexpected error processing request for %s", request.path)
err_info = (502, 'Unexpected error: {}'.format(err))
status, msg = err_info
return view.json_message(msg, status_code=status,
message_code=err.__class__.__name__)
return view.json_message(
msg, status_code=status,
message_code=err.__class__.__name__.lower())
return error_handler