Improve cloud error handling (#20729)

* Improve cloud error handling

* Lint
This commit is contained in:
Paulus Schoutsen authored and Pascal Vizeli committed 2019-02-04 10:14:30 +01:00
1 parent a3c8439ce2
commit 07b5b68a51
2 files changed
+18 -3

No files matched your search

+6 -3
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