Skip to content

Commit

Permalink
Make sure there is always an error message
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasddn committed Jan 19, 2025
1 parent e57b315 commit f28dc41
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion custom_components/volvo_cars/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ async def _async_update_data(self) -> CoordinatorData:
_LOGGER.debug(
"%s - Error during data update: %s",
self.config_entry.entry_id,
result,
result.message,
)
exception = exception or result
continue
Expand Down
6 changes: 3 additions & 3 deletions custom_components/volvo_cars/volvo/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,13 @@ async def _async_request(
redacted_exception = RedactedClientResponseError(ex, self._vin)

if ex.status in (401, 403):
raise VolvoAuthException from redacted_exception
raise VolvoAuthException(ex.message) from redacted_exception

raise VolvoApiException from redacted_exception
raise VolvoApiException(ex.message) from redacted_exception

except (ClientError, TimeoutError) as ex:
_LOGGER.debug("Request [%s] error: %s", operation, ex)
raise VolvoApiException from ex
raise VolvoApiException(ex.__class__.__name__) from ex


class RedactedClientResponseError(ClientResponseError):
Expand Down
8 changes: 4 additions & 4 deletions custom_components/volvo_cars/volvo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,10 @@ class AuthorizationModel:
class VolvoApiException(Exception):
"""Thrown when an API request fails."""

def __init__(self, message: str = "") -> None:
"""Initialize exception."""
self.message = message


class VolvoAuthException(VolvoApiException):
"""Thrown when the authentication fails."""

def __init__(self, message: str = "") -> None:
"""Initialze exception."""
self.message = message

0 comments on commit f28dc41

Please sign in to comment.