Errors
List of error classes OpenPO implements.
APIError
¶
Bases: Exception
Base exception class for API-related errors.
This class serves as the base for all API-related exceptions in the openpo library. It provides detailed error information including status codes, response data, and specific error messages.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message
|
str
|
Human-readable error message describing the issue |
required |
status_code
|
Optional[int]
|
HTTP status code associated with the error |
None
|
response
|
Optional[Dict]
|
Raw response data from the API |
None
|
error
|
Optional[str]
|
Specific error code or identifier |
None
|
Attributes:
Name | Type | Description |
---|---|---|
message |
str
|
The error message |
status_code |
Optional[int]
|
The HTTP status code |
response |
Optional[Dict]
|
The raw API response |
error |
Optional[str]
|
The error identifier |
Source code in openpo/internal/error.py
AuthenticationError
¶
Bases: APIError
Exception raised for API authentication failures.
This exception is raised when there are issues with API authentication, such as invalid API keys, expired tokens, or missing credentials.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
provider
|
str
|
Name of the provider (e.g., 'OpenAI', 'Anthropic') |
required |
message
|
Optional[str]
|
Custom error message. If not provided, a default message will be generated using the provider name |
None
|
status_code
|
Optional[int]
|
HTTP status code from the authentication attempt |
None
|
response
|
Optional[Dict]
|
Raw response data from the authentication attempt |
None
|
Source code in openpo/internal/error.py
ProviderError
¶
Bases: APIError
Exception raised for provider-specific errors.
This exception is raised when a provider returns an error that is specific to their service, such as rate limits, invalid model names, or service-specific validation errors.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
provider
|
str
|
Name of the provider (e.g., 'OpenAI', 'Anthropic') |
required |
message
|
str
|
Detailed error message from the provider |
required |
status_code
|
Optional[int]
|
HTTP status code from the provider |
None
|
response
|
Optional[Dict]
|
Raw response data from the provider |
None
|
Source code in openpo/internal/error.py
InvalidJSONFormatError
¶
Bases: JSONExtractionError
Exception raised when JSON extraction or parsing fails.
This exception is raised when attempting to extract or parse JSON content that is not properly formatted or is invalid according to JSON specifications.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message
|
Optional[str]
|
Custom error message. If not provided, a default message indicating invalid JSON format will be used. |
None
|