Skip to content

Commit f0ddb85

Browse files
committed
Shorten ServerResponseError to ServerError
1 parent 8b89b7d commit f0ddb85

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

pydexcom/dexcom.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
ArgumentError,
2525
ArgumentErrorEnum,
2626
DexcomError,
27-
ServerResponseError,
28-
ServerResponseErrorEnum,
27+
ServerError,
28+
ServerErrorEnum,
2929
SessionError,
3030
SessionErrorEnum,
3131
)
@@ -101,9 +101,7 @@ def _post(
101101
raise self._handle_error_code(response_json) from http_error
102102
except requests.JSONDecodeError as json_error:
103103
_LOGGER.exception("JSON decode error: %s", response.text)
104-
raise ServerResponseError(
105-
ServerResponseErrorEnum.INVALID_JSON
106-
) from json_error
104+
raise ServerError(ServerErrorEnum.INVALID_JSON) from json_error
107105
else:
108106
return response_json
109107

@@ -138,9 +136,9 @@ def _handle_error_code(self, json: dict[str, Any]) -> DexcomError: # noqa: C901
138136
return ArgumentError(ArgumentErrorEnum.ACCOUNT_ID_INVALID)
139137
if code and message:
140138
_LOGGER.error("%s: %s", code, message)
141-
return ServerResponseError(ServerResponseErrorEnum.UNKNOWN_CODE)
139+
return ServerError(ServerErrorEnum.UNKNOWN_CODE)
142140
_LOGGER.error("%s", json)
143-
return ServerResponseError(ServerResponseErrorEnum.UNEXPECTED)
141+
return ServerError(ServerErrorEnum.UNEXPECTED)
144142

145143
def _validate_region(self, region: Region) -> None:
146144
if region not in list(Region):

pydexcom/errors.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ class ArgumentErrorEnum(DexcomErrorEnum):
3838
GLUCOSE_READING_INVALID = "JSON glucose reading incorrectly formatted"
3939

4040

41-
class ServerResponseErrorEnum(DexcomErrorEnum):
42-
"""`ServerResponseError` strings."""
41+
class ServerErrorEnum(DexcomErrorEnum):
42+
"""`ServerErrorEnum` strings."""
4343

4444
INVALID_JSON = "Invalid or malformed JSON in server response"
4545
UNKNOWN_CODE = "Unknown error code in server response"
@@ -80,5 +80,5 @@ class ArgumentError(DexcomError):
8080
"""Errors involving `pydexcom` arguments."""
8181

8282

83-
class ServerResponseError(DexcomError):
83+
class ServerError(DexcomError):
8484
"""Errors involving unexpected or malformed server responses."""

0 commit comments

Comments
 (0)