Errors

Every error raised by ogu-api inherits from OGUError. HTTP-layer failures are mapped to specific subclasses based on status code:

Status

Exception

401

OGUAuthenticationError

403

OGUAuthorizationError

404

OGUNotFoundError

400 / 422

OGUValidationError

429

OGURateLimitError (carries retry_after_seconds)

5xx

OGUServerError

network

OGUNetworkError

timeout

OGUTimeoutError (subclass of network)

Domain-level errors:

Exception

Raised when

OGUParseError

A page came back, but the HTML couldn’t be parsed (e.g. a profile with no user_id extractable).

OGUSessionError

The session cookie is missing or expired.

OGULoginError

Login flow failed.

OGUReputationError

Sending reputation with an amount the target’s page didn’t list. Carries valid_amounts.

OGUCreditsError

Sending credits failed.

Hierarchy

OGUError
├── OGUAPIError
│   ├── OGUAuthenticationError
│   ├── OGUAuthorizationError
│   ├── OGUNotFoundError
│   ├── OGUValidationError
│   ├── OGURateLimitError
│   └── OGUServerError
├── OGUNetworkError
│   └── OGUTimeoutError
├── OGUParseError
├── OGUSessionError
├── OGULoginError
├── OGUReputationError
└── OGUCreditsError

Catch specific errors

from ogu_api import OGUNotFoundError, OGURateLimitError

try:
    await client.users.get_by_username('does-not-exist')

except OGUNotFoundError as E:
    print(f'not found: {E.method} {E.url}')

except OGURateLimitError as E:
    print(f'rate limited, retry after {E.retry_after_seconds}s')

OGUAPIError instances expose status_code, method, url, and the response body for inspection.