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 |
|
403 |
|
404 |
|
400 / 422 |
|
429 |
|
5xx |
|
network |
|
timeout |
|
Domain-level errors:
Exception |
Raised when |
|---|---|
|
A page came back, but the HTML couldn’t be parsed (e.g. a profile with no |
|
The session cookie is missing or expired. |
|
Login flow failed. |
|
Sending reputation with an amount the target’s page didn’t list. Carries |
|
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.