Skip to content

Commit

Permalink
Merge pull request #524 from uvjim/config-flow-exception-handling
Browse files Browse the repository at this point in the history
  • Loading branch information
uvjim authored Nov 29, 2024
2 parents 45fedd3 + 9d16b13 commit 6c5c82d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 7 additions & 0 deletions custom_components/linksys_velop/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,9 @@ def _set_error(self, exc: MeshException) -> None:
elif isinstance(exc, MeshTimeoutError):
_LOGGER.debug(self._log_formatter.format("timeout"))
self._errors["base"] = "node_timeout"
else:
_LOGGER.debug(self._log_formatter.format(f"{type(exc)} - {exc}"))
self._errors["base"] = "general"

async def _async_task_gather_details(self) -> None:
"""Gather the details about the Mesh."""
Expand All @@ -329,6 +332,8 @@ async def _async_task_gather_details(self) -> None:
await self._mesh.async_initialise()
except MeshException as exc:
self._set_error(exc)
except Exception as exc:
self._set_error(exc)
else:
_LOGGER.debug(self._log_formatter.format("no exceptions"))

Expand All @@ -350,6 +355,8 @@ async def _async_task_login(self, details) -> None:
self._mesh = _mesh
except MeshException as exc:
self._set_error(exc)
except Exception as exc:
self._set_error(exc)
else:
_LOGGER.debug(self._log_formatter.format("no exceptions"))

Expand Down
5 changes: 3 additions & 2 deletions custom_components/linksys_velop/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
},
"error": {
"connection_error": "Connection error.",
"general": "An error occurred.",
"invalid_input": "Invalid action in request.",
"login_error": "Unable to login. Please check the username and password.",
"login_bad_response": "Bad response on login. Check that the primary node is correct.",
"login_error": "Unable to login. Please check the username and password.",
"login_bad_response": "Bad response on login. Check that the primary node is correct.",
"node_not_primary": "The primary node in the Velop mesh should be specified.",
"node_timeout": "Timeout whilst contacting the node."
},
Expand Down

0 comments on commit 6c5c82d

Please sign in to comment.