Skip to content

Exceptions Reference

pydiagral.exceptions

Module defining custom exceptions for the Diagral API.

DiagralAPIError

Bases: Exception

Base exception for Diagral API errors.

Source code in src/pydiagral/exceptions.py
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
class DiagralAPIError(Exception):
    """Base exception for Diagral API errors."""

    def __init__(self, message: str, status_code: int | None = None) -> None:
        """Initialize the DiagralAPIError.

        :param message: The error message.
        :param status_code: The status code of the error, if any.
        """
        self.message: str = message
        self.status_code: int | None = status_code
        super().__init__(self.message)

__init__(message, status_code=None)

Initialize the DiagralAPIError.

:param message: The error message. :param status_code: The status code of the error, if any.

Source code in src/pydiagral/exceptions.py
 7
 8
 9
10
11
12
13
14
15
def __init__(self, message: str, status_code: int | None = None) -> None:
    """Initialize the DiagralAPIError.

    :param message: The error message.
    :param status_code: The status code of the error, if any.
    """
    self.message: str = message
    self.status_code: int | None = status_code
    super().__init__(self.message)

ConfigurationError

Bases: DiagralAPIError

Raised when configuration is invalid.

Source code in src/pydiagral/exceptions.py
18
19
class ConfigurationError(DiagralAPIError):
    """Raised when configuration is invalid."""

SessionError

Bases: DiagralAPIError

Raised when session is invalid.

Source code in src/pydiagral/exceptions.py
22
23
class SessionError(DiagralAPIError):
    """Raised when session is invalid."""

AuthenticationError

Bases: DiagralAPIError

Raised when authentication fails.

Source code in src/pydiagral/exceptions.py
26
27
class AuthenticationError(DiagralAPIError):
    """Raised when authentication fails."""

ValidationError

Bases: DiagralAPIError

Raised when validation fails.

Source code in src/pydiagral/exceptions.py
30
31
class ValidationError(DiagralAPIError):
    """Raised when validation fails."""

ServerError

Bases: DiagralAPIError

Raised when server returns 5xx error.

Source code in src/pydiagral/exceptions.py
34
35
class ServerError(DiagralAPIError):
    """Raised when server returns 5xx error."""

ClientError

Bases: DiagralAPIError

Raised when client returns error.

Source code in src/pydiagral/exceptions.py
38
39
class ClientError(DiagralAPIError):
    """Raised when client returns error."""

APIKeyCreationError

Bases: DiagralAPIError

Raised when API key creation fails.

Source code in src/pydiagral/exceptions.py
42
43
class APIKeyCreationError(DiagralAPIError):
    """Raised when API key creation fails."""

APIValidationError

Bases: DiagralAPIError

Raised when API validation fails.

Source code in src/pydiagral/exceptions.py
46
47
class APIValidationError(DiagralAPIError):
    """Raised when API validation fails."""