Improve error messages in Habitica (#129948)

Improve error messages
This commit is contained in:
Manu 2024-11-06 13:23:43 +01:00 committed by Franck Nijhof
parent dfc3423c83
commit 795384ca2d
No known key found for this signature in database
GPG key ID: D62583BA8AB11CA3
4 changed files with 7 additions and 7 deletions

View file

@ -59,9 +59,9 @@ class HabiticaDataUpdateCoordinator(DataUpdateCoordinator[HabiticaData]):
tasks_response.extend(await self.api.tasks.user.get(type="completedTodos"))
except ClientResponseError as error:
if error.status == HTTPStatus.TOO_MANY_REQUESTS:
_LOGGER.debug("Currently rate limited, skipping update")
_LOGGER.debug("Rate limit exceeded, will try again later")
return self.data
raise UpdateFailed(f"Error communicating with API: {error}") from error
raise UpdateFailed(f"Unable to connect to Habitica: {error}") from error
return HabiticaData(user=user_response, tasks=tasks_response)

View file

@ -204,10 +204,10 @@
"message": "Unable to create new to-do `{name}` for Habitica, please try again"
},
"setup_rate_limit_exception": {
"message": "Currently rate limited, try again later"
"message": "Rate limit exceeded, try again later"
},
"service_call_unallowed": {
"message": "Unable to carry out this action, because the required conditions are not met"
"message": "Unable to complete action, the required conditions are not met"
},
"service_call_exception": {
"message": "Unable to connect to Habitica, try again later"

View file

@ -207,7 +207,7 @@ async def test_button_press(
[
(
HTTPStatus.TOO_MANY_REQUESTS,
"Currently rate limited",
"Rate limit exceeded, try again later",
ServiceValidationError,
),
(
@ -217,7 +217,7 @@ async def test_button_press(
),
(
HTTPStatus.UNAUTHORIZED,
"Unable to carry out this action",
"Unable to complete action, the required conditions are not met",
ServiceValidationError,
),
],

View file

@ -165,4 +165,4 @@ async def test_coordinator_rate_limited(
async_fire_time_changed(hass)
await hass.async_block_till_done()
assert "Currently rate limited, skipping update" in caplog.text
assert "Rate limit exceeded, will try again later" in caplog.text