Skip to content

⚠️ Exceptions

All Oinker exceptions inherit from OinkerError for easy catching.

from oinker import OinkerError

try:
    await piglet.dns.list("example.com")
except OinkerError as e:
    print(f"Something went wrong: {e}")

Exception Hierarchy

OinkerError
├── AuthenticationError
├── AuthorizationError
├── RateLimitError
├── NotFoundError
├── ValidationError
└── APIError

Exceptions

OinkerError

oinker.OinkerError

Bases: Exception

Base exception for all oinker errors.

Catch this to handle any oinker-related error.

AuthenticationError

oinker.AuthenticationError

Bases: OinkerError

Invalid or missing API credentials.

Oops! Couldn't authenticate. Check your API keys aren't hogwash.

AuthorizationError

oinker.AuthorizationError

Bases: OinkerError

Valid credentials but not authorized for this domain/action.

You're authenticated, but this pen isn't yours to root around in.

RateLimitError

oinker.RateLimitError

RateLimitError(
    message: str, retry_after: float | None = None
)

Bases: OinkerError

Rate limit exceeded.

Whoa there! Slow your trot. Try again later.

Initialize with optional retry delay.

Parameters:

Name Type Description Default
message str

Error message.

required
retry_after float | None

Seconds to wait before retrying.

None
Source code in src/oinker/_exceptions.py
def __init__(self, message: str, retry_after: float | None = None) -> None:
    """Initialize with optional retry delay.

    Args:
        message: Error message.
        retry_after: Seconds to wait before retrying.
    """
    super().__init__(message)
    self.retry_after = retry_after

NotFoundError

oinker.NotFoundError

Bases: OinkerError

Domain or record not found.

Couldn't find that in the pen. Double-check the domain/record ID.

ValidationError

oinker.ValidationError

Bases: OinkerError

Invalid record data.

That data doesn't pass the sniff test. Check your input.

APIError

oinker.APIError

APIError(message: str, status_code: int | None = None)

Bases: OinkerError

Generic API error with status code and message.

Something went wrong at the farm. Check the details.

Initialize with status code.

Parameters:

Name Type Description Default
message str

Error message from the API.

required
status_code int | None

HTTP status code if available.

None
Source code in src/oinker/_exceptions.py
def __init__(self, message: str, status_code: int | None = None) -> None:
    """Initialize with status code.

    Args:
        message: Error message from the API.
        status_code: HTTP status code if available.
    """
    super().__init__(message)
    self.status_code = status_code
    self.message = message