aixplain.v2.exceptions
Unified error hierarchy for v2 system.
This module provides a comprehensive set of error types for consistent error handling across all v2 components.
AixplainV2Error Objects
class AixplainV2Error(Exception)
Base exception for all v2 errors.
__init__
def __init__(message: Union[str, List[str]],
details: Optional[Dict[str, Any]] = None) -> None
Initialize the exception with a message and optional details.
Arguments:
message- Error message string or list of error messages.details- Optional dictionary with additional error details.
ResourceError Objects
class ResourceError(AixplainV2Error)
Raised when resource operations fail.
APIError Objects
class APIError(AixplainV2Error)
Raised when API calls fail.
__init__
def __init__(message: Union[str, List[str]],
status_code: int = 0,
response_data: Optional[Dict[str, Any]] = None,
error: Optional[str] = None,
retryable: Optional[bool] = None) -> None
Initialize APIError with HTTP status and response details.
Arguments:
message- Error message string or list of error messages.status_code- HTTP status code from the API response.response_data- Optional dictionary containing the raw API response.error- Optional error string override.retryable- Explicit retry signal, tri-state.None(the default) means "no opinion" — callers fall back to the status-code heuristic, where0stands for "no HTTP response at all".Falsemarks a deterministic failure that re-submitting cannot fix; a businessFAILEDresponse is the motivating case, because its usually-absentstatusCodecollapses onto that same0transport sentinel.
AixplainIssueError Objects
class AixplainIssueError(APIError)
Raised when SDK issue reporting fails.
ValidationError Objects
class ValidationError(AixplainV2Error)
Raised when validation fails.
TimeoutError Objects
class TimeoutError(AixplainV2Error)
Raised when operations timeout.
FileUploadError Objects
class FileUploadError(AixplainV2Error)
Raised when file upload operations fail.
UntrustedURLError Objects
class UntrustedURLError(AixplainV2Error)
Raised when a credentialed request targets a host outside the trusted set.
Not an APIError: no request is made, so there is no status code to
report. Poll URLs come from response bodies, so this is the SDK refusing to
hand the team API key to a host a body asked it to talk to.
create_operation_failed_error
def create_operation_failed_error(response: Dict[str, Any]) -> APIError
Create an operation failed error from API response.
The error is always marked non-retryable: a FAILED body reports a
business outcome, and its statusCode (usually absent, hence 0) is
not a transport code. Without the explicit flag it would be indistinguishable
from a connection failure and re-POSTed, billing the customer again for the
same deterministic failure (BUG-1090).