Skip to content

Exceptions

glpi_utils.exceptions.GlpiError

Bases: Exception

Base exception for all glpi_utils errors.

Source code in glpi_utils/exceptions.py
class GlpiError(Exception):
    """Base exception for all glpi_utils errors."""

glpi_utils.exceptions.GlpiAPIError

Bases: GlpiError

Raised when the GLPI server returns an API-level error response.

Attributes:

Name Type Description
status_code int or None

HTTP status code returned by the server.

error_code str or None

GLPI error identifier (e.g. "ERROR_SESSION_TOKEN_INVALID").

message str

Human-readable error message.

Source code in glpi_utils/exceptions.py
class GlpiAPIError(GlpiError):
    """Raised when the GLPI server returns an API-level error response.

    Attributes
    ----------
    status_code : int or None
        HTTP status code returned by the server.
    error_code : str or None
        GLPI error identifier (e.g. ``"ERROR_SESSION_TOKEN_INVALID"``).
    message : str
        Human-readable error message.
    """

    def __init__(
        self,
        message: str,
        status_code: Optional[int] = None,
        error_code: Optional[str] = None,
    ) -> None:
        super().__init__(message)
        self.status_code = status_code
        self.error_code = error_code
        self.message = message

    def __repr__(self) -> str:
        return (
            f"{self.__class__.__name__}("
            f"status_code={self.status_code!r}, "
            f"error_code={self.error_code!r}, "
            f"message={self.message!r})"
        )

glpi_utils.exceptions.GlpiAuthError

Bases: GlpiAPIError

Raised on authentication failures (HTTP 401 or invalid session token).

Source code in glpi_utils/exceptions.py
class GlpiAuthError(GlpiAPIError):
    """Raised on authentication failures (HTTP 401 or invalid session token)."""

glpi_utils.exceptions.GlpiNotFoundError

Bases: GlpiAPIError

Raised when the requested resource does not exist (HTTP 404).

Source code in glpi_utils/exceptions.py
class GlpiNotFoundError(GlpiAPIError):
    """Raised when the requested resource does not exist (HTTP 404)."""

glpi_utils.exceptions.GlpiPermissionError

Bases: GlpiAPIError

Raised when the authenticated user lacks the required rights (HTTP 403).

Source code in glpi_utils/exceptions.py
class GlpiPermissionError(GlpiAPIError):
    """Raised when the authenticated user lacks the required rights (HTTP 403)."""

glpi_utils.exceptions.GlpiConnectionError

Bases: GlpiError

Raised when a network or transport error occurs.

Source code in glpi_utils/exceptions.py
class GlpiConnectionError(GlpiError):
    """Raised when a network or transport error occurs."""