Source code for datamasque.client.exceptions
from requests import Response
[docs]
class DataMasqueException(Exception):
"""Generic exception base class."""
[docs]
class DataMasqueUserError(DataMasqueException):
"""Raised when error occurs during user creation or configuration."""
[docs]
class DataMasqueApiError(DataMasqueException):
"""
Raised when the DataMasque server responds to a request with a non-2xx status code.
The triggering `Response` is always available on the `.response` attribute,
so callers can inspect the status code, headers, and body for richer error handling.
502 Bad Gateway responses are raised as `DataMasqueNotReadyError` instead.
"""
def __init__(self, message: str, *, response: Response) -> None:
super().__init__(message)
self.response = response
[docs]
class FailedToStartError(DataMasqueApiError):
"""
Raised when `start_masking_run` fails to create the run.
Inherits `.response` from `DataMasqueApiError`,
so callers can read the server's status code and error body directly.
"""
[docs]
class InvalidRulesetError(FailedToStartError):
"""Specific error for when runs fail to start due to having an invalid ruleset."""
[docs]
class InvalidLibraryError(FailedToStartError):
"""Specific error for when runs fail to start due to having an invalid ruleset library."""
[docs]
class InvalidDiscoveryConfigError(FailedToStartError):
"""
Raised when a discovery run fails to start because the referenced config is present but unusable.
The config exists but is not in a `valid` validation state, or its YAML is rejected when the run starts.
A config that cannot be found raises `DiscoveryConfigNotFoundError` instead.
"""
[docs]
class DiscoveryConfigNotFoundError(FailedToStartError):
"""
Raised when a discovery run references a discovery config that cannot be found.
The config does not exist or is the wrong type for the run.
"""
[docs]
class DataMasqueTransportError(DataMasqueException):
"""
Raised when a request to the DataMasque server fails before any response is received.
Covers connection refused, timeout, DNS failure, SSL handshake failure,
and similar transport-layer errors.
The originating `requests` exception is chained via `__cause__`.
"""
[docs]
class DataMasqueNotReadyError(DataMasqueException):
"""Raised when the DataMasque server is not healthy, normally because it is still starting up."""
[docs]
class AsyncRulesetGenerationInProgressError(DataMasqueException):
"""Raised when attempting to retrieve results from a ruleset generation request that has not yet completed."""
[docs]
class DataMasqueIfmError(DataMasqueException):
"""Generic base exception for IFM (in-flight masking) client errors."""
[docs]
class IfmAuthError(DataMasqueIfmError):
"""Raised when the IFM client cannot obtain or refresh a JWT (e.g. invalid credentials, missing scope)."""
[docs]
class SpcsGatewayAuthError(DataMasqueException):
"""
Raised when a Snowflake SPCS app gateway rejects the configured `spcs_pat`.
The message includes the Snowflake-provided detail, request id,
and a hint at the likely cause
(for example an expired token, or a network policy that excludes your IP).
Deliberately a direct subclass of `DataMasqueException` rather than
`DataMasqueApiError`:
the client's 401 re-authenticate-and-retry path keys off `DataMasqueApiError`,
so keeping this outside that subtree
ensures a gateway rejection aborts immediately instead of looping.
"""
[docs]
class RunNotCancellableError(DataMasqueUserError):
"""
Raised when `cancel_run` is called against a run that is no longer eligible for cancellation.
Typically this happens when the run is already finished, failed, or in the cancelling state itself.
"""