pydexcom.errors

Errors used in pydexcom.

 1"""Errors used in `pydexcom`."""
 2
 3from enum import Enum
 4
 5
 6class DexcomErrorEnum(Enum):
 7    """Base class for all `pydexcom` error strings."""
 8
 9
10class AccountErrorEnum(DexcomErrorEnum):
11    """`AccountError` strings."""
12
13    FAILED_AUTHENTICATION = "Failed to authenticate"
14    MAX_ATTEMPTS = "Maximum authentication attempts exceeded"
15
16
17class SessionErrorEnum(DexcomErrorEnum):
18    """`SessionError` strings."""
19
20    NOT_FOUND = "Session ID not found"
21    INVALID = "Session not active or timed out"
22
23
24class ArgumentErrorEnum(DexcomErrorEnum):
25    """`ArgumentError` strings."""
26
27    MINUTES_INVALID = "Minutes must be and integer between 1 and 1440"
28    MAX_COUNT_INVALID = "Max count must be and integer between 1 and 288"
29    USERNAME_INVALID = "Username must be non-empty string"
30    USER_ID_MULTIPLE = "Only one of account_id, username should be provided"
31    USER_ID_REQUIRED = "At least one of account_id, username should be provided"
32    PASSWORD_INVALID = "Password must be non-empty string"  # noqa: S105
33    REGION_INVALID = "Region must be 'us', 'ous, or 'jp'"
34    ACCOUNT_ID_INVALID = "Account ID must be UUID"
35    ACCOUNT_ID_DEFAULT = "Account ID default"
36    SESSION_ID_INVALID = "Session ID must be UUID"
37    SESSION_ID_DEFAULT = "Session ID default"
38    GLUCOSE_READING_INVALID = "JSON glucose reading incorrectly formatted"
39
40
41class DexcomError(Exception):
42    """Base class for all `pydexcom` errors."""
43
44    def __init__(self, enum: DexcomErrorEnum) -> None:
45        """
46        Create `DexcomError` from `DexcomErrorEnum`.
47
48        :param enum: associated `DexcomErrorEnum`
49        """
50        super().__init__(enum.value)
51        self._enum = enum
52
53    @property
54    def enum(self) -> DexcomErrorEnum:
55        """
56        Get `DexcomErrorEnum` associated with error.
57
58        :return: `DexcomErrorEnum`
59        """
60        return self._enum
61
62
63class AccountError(DexcomError):
64    """Errors involving Dexcom Share API credentials."""
65
66
67class SessionError(DexcomError):
68    """Errors involving Dexcom Share API session."""
69
70
71class ArgumentError(DexcomError):
72    """Errors involving `pydexcom` arguments."""
class DexcomErrorEnum(enum.Enum):
7class DexcomErrorEnum(Enum):
8    """Base class for all `pydexcom` error strings."""

Base class for all pydexcom error strings.

class AccountErrorEnum(DexcomErrorEnum):
11class AccountErrorEnum(DexcomErrorEnum):
12    """`AccountError` strings."""
13
14    FAILED_AUTHENTICATION = "Failed to authenticate"
15    MAX_ATTEMPTS = "Maximum authentication attempts exceeded"

AccountError strings.

FAILED_AUTHENTICATION = <AccountErrorEnum.FAILED_AUTHENTICATION: 'Failed to authenticate'>
MAX_ATTEMPTS = <AccountErrorEnum.MAX_ATTEMPTS: 'Maximum authentication attempts exceeded'>
class SessionErrorEnum(DexcomErrorEnum):
18class SessionErrorEnum(DexcomErrorEnum):
19    """`SessionError` strings."""
20
21    NOT_FOUND = "Session ID not found"
22    INVALID = "Session not active or timed out"

SessionError strings.

NOT_FOUND = <SessionErrorEnum.NOT_FOUND: 'Session ID not found'>
INVALID = <SessionErrorEnum.INVALID: 'Session not active or timed out'>
class ArgumentErrorEnum(DexcomErrorEnum):
25class ArgumentErrorEnum(DexcomErrorEnum):
26    """`ArgumentError` strings."""
27
28    MINUTES_INVALID = "Minutes must be and integer between 1 and 1440"
29    MAX_COUNT_INVALID = "Max count must be and integer between 1 and 288"
30    USERNAME_INVALID = "Username must be non-empty string"
31    USER_ID_MULTIPLE = "Only one of account_id, username should be provided"
32    USER_ID_REQUIRED = "At least one of account_id, username should be provided"
33    PASSWORD_INVALID = "Password must be non-empty string"  # noqa: S105
34    REGION_INVALID = "Region must be 'us', 'ous, or 'jp'"
35    ACCOUNT_ID_INVALID = "Account ID must be UUID"
36    ACCOUNT_ID_DEFAULT = "Account ID default"
37    SESSION_ID_INVALID = "Session ID must be UUID"
38    SESSION_ID_DEFAULT = "Session ID default"
39    GLUCOSE_READING_INVALID = "JSON glucose reading incorrectly formatted"

ArgumentError strings.

MINUTES_INVALID = <ArgumentErrorEnum.MINUTES_INVALID: 'Minutes must be and integer between 1 and 1440'>
MAX_COUNT_INVALID = <ArgumentErrorEnum.MAX_COUNT_INVALID: 'Max count must be and integer between 1 and 288'>
USERNAME_INVALID = <ArgumentErrorEnum.USERNAME_INVALID: 'Username must be non-empty string'>
USER_ID_MULTIPLE = <ArgumentErrorEnum.USER_ID_MULTIPLE: 'Only one of account_id, username should be provided'>
USER_ID_REQUIRED = <ArgumentErrorEnum.USER_ID_REQUIRED: 'At least one of account_id, username should be provided'>
PASSWORD_INVALID = <ArgumentErrorEnum.PASSWORD_INVALID: 'Password must be non-empty string'>
REGION_INVALID = <ArgumentErrorEnum.REGION_INVALID: "Region must be 'us', 'ous, or 'jp'">
ACCOUNT_ID_INVALID = <ArgumentErrorEnum.ACCOUNT_ID_INVALID: 'Account ID must be UUID'>
ACCOUNT_ID_DEFAULT = <ArgumentErrorEnum.ACCOUNT_ID_DEFAULT: 'Account ID default'>
SESSION_ID_INVALID = <ArgumentErrorEnum.SESSION_ID_INVALID: 'Session ID must be UUID'>
SESSION_ID_DEFAULT = <ArgumentErrorEnum.SESSION_ID_DEFAULT: 'Session ID default'>
GLUCOSE_READING_INVALID = <ArgumentErrorEnum.GLUCOSE_READING_INVALID: 'JSON glucose reading incorrectly formatted'>
class DexcomError(builtins.Exception):
42class DexcomError(Exception):
43    """Base class for all `pydexcom` errors."""
44
45    def __init__(self, enum: DexcomErrorEnum) -> None:
46        """
47        Create `DexcomError` from `DexcomErrorEnum`.
48
49        :param enum: associated `DexcomErrorEnum`
50        """
51        super().__init__(enum.value)
52        self._enum = enum
53
54    @property
55    def enum(self) -> DexcomErrorEnum:
56        """
57        Get `DexcomErrorEnum` associated with error.
58
59        :return: `DexcomErrorEnum`
60        """
61        return self._enum

Base class for all pydexcom errors.

DexcomError(enum: DexcomErrorEnum)
45    def __init__(self, enum: DexcomErrorEnum) -> None:
46        """
47        Create `DexcomError` from `DexcomErrorEnum`.
48
49        :param enum: associated `DexcomErrorEnum`
50        """
51        super().__init__(enum.value)
52        self._enum = enum

Create DexcomError from DexcomErrorEnum.

Parameters
enum: DexcomErrorEnum
54    @property
55    def enum(self) -> DexcomErrorEnum:
56        """
57        Get `DexcomErrorEnum` associated with error.
58
59        :return: `DexcomErrorEnum`
60        """
61        return self._enum

Get DexcomErrorEnum associated with error.

Returns

DexcomErrorEnum

class AccountError(DexcomError):
64class AccountError(DexcomError):
65    """Errors involving Dexcom Share API credentials."""

Errors involving Dexcom Share API credentials.

Inherited Members
DexcomError
DexcomError
enum
class SessionError(DexcomError):
68class SessionError(DexcomError):
69    """Errors involving Dexcom Share API session."""

Errors involving Dexcom Share API session.

Inherited Members
DexcomError
DexcomError
enum
class ArgumentError(DexcomError):
72class ArgumentError(DexcomError):
73    """Errors involving `pydexcom` arguments."""

Errors involving pydexcom arguments.

Inherited Members
DexcomError
DexcomError
enum