Skip to content

Commit

Permalink
Add better error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
iMicknl committed Aug 9, 2024
1 parent 67a02b1 commit 1e5c671
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion custom_components/sagemcom_fast/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
except (AuthenticationException, UnauthorizedException) as exception:
LOGGER.error("Invalid_auth")
raise ConfigEntryAuthFailed("Invalid credentials") from exception
except (TimeoutError, ClientError) as exception:
except (TimeoutError, ClientError, ConnectionError) as exception:
LOGGER.error("Failed to connect")
raise ConfigEntryNotReady("Failed to connect") from exception
except MaximumSessionCountException as exception:
Expand Down
2 changes: 1 addition & 1 deletion custom_components/sagemcom_fast/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ async def async_step_user(self, user_input=None):
errors["base"] = "access_restricted"
except AuthenticationException:
errors["base"] = "invalid_auth"
except (TimeoutError, ClientError):
except (TimeoutError, ClientError, ConnectionError):
errors["base"] = "cannot_connect"
except LoginTimeoutException:
errors["base"] = "login_timeout"
Expand Down
2 changes: 1 addition & 1 deletion custom_components/sagemcom_fast/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async def _async_update_data(self) -> dict[str, Device]:
raise ConfigEntryAuthFailed("Access restricted") from exception
except (AuthenticationException, UnauthorizedException) as exception:
raise ConfigEntryAuthFailed("Invalid credentials") from exception
except (TimeoutError, ClientError) as exception:
except (TimeoutError, ClientError, ConnectionError) as exception:
raise UpdateFailed("Failed to connect") from exception
except LoginRetryErrorException as exception:
raise UpdateFailed(
Expand Down
2 changes: 1 addition & 1 deletion custom_components/sagemcom_fast/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"ssl": "Uses an SSL certificate",
"verify_ssl": "Verify SSL certificate"
},
"description": "Enter your credentials for accessing the routers web interface. Depending on the router model, Sagemcom is using different encryption methods for authentication, which can be found in the [supported devices](https://github.com/iMicknl/ha-sagemcom-fast#supported-devices) list."
"description": "Enter your credentials for accessing the router's web interface. The first login may take longer (up to a minute) as we retrieve the encryption method used by your router. For more information, see the [supported devices](https://github.com/iMicknl/ha-sagemcom-fast#supported-devices)."
}
}
},
Expand Down

0 comments on commit 1e5c671

Please sign in to comment.