aixplain.exceptions.types
Exception types and error handling for the aiXplain SDK.
ErrorSeverity Objects
class ErrorSeverity(str, Enum)
Enumeration of error severity levels in the aiXplain system.
This enum defines the different levels of severity that can be assigned to errors, ranging from informational messages to critical system errors.
Attributes:
INFOstr - Informational message, not an actual error.WARNINGstr - Warning that doesn't prevent operation completion.ERRORstr - Error condition that prevents operation completion.CRITICALstr - Severe error that might affect system stability.
INFO
Informational, not an error
WARNING
Warning, operation can continue
ERROR
Error, operation cannot continue
CRITICAL
System stability might be compromised
ErrorCategory Objects
class ErrorCategory(Enum)
Enumeration of error categories in the aiXplain system.
This enum defines the different domains or areas where errors can occur, helping to classify and organize error handling.
Attributes:
AUTHENTICATIONstr - Authentication and authorization errors.VALIDATIONstr - Input validation errors.RESOURCEstr - Resource availability and access errors.BILLINGstr - Billing and payment-related errors.SUPPLIERstr - External supplier and third-party service errors.NETWORKstr - Network connectivity errors.SERVICEstr - Service availability errors.INTERNALstr - Internal system errors.AGENTstr - Agent-specific errors.UNKNOWNstr - Uncategorized or unclassified errors.
AUTHENTICATION
API keys, permissions
VALIDATION
Input validation
RESOURCE
Resource availability
BILLING
Credits, payment
SUPPLIER
External supplier issues
NETWORK
Network connectivity
SERVICE
Service availability
INTERNAL
Internal system errors
AGENT
Agent-specific errors
UNKNOWN
Uncategorized errors
ErrorCode Objects
class ErrorCode(str, Enum)
Standard error codes for aiXplain exceptions.
The format is AX-<CATEGORY>-<ID>, where <CATEGORY> is a short identifier derived from the ErrorCategory (e.g., AUTH, VAL, RES) and <ID> is a unique sequential number within that category, starting from 1000.
How to Add a New Error Code:
- Identify the appropriate
ErrorCategoryfor the new error. - Determine the next available sequential ID within that category.
For example, if
AX-AUTH-1000exists, the next authentication-specific error could beAX-AUTH-1001. - Define the new enum member using the format
AX-<CATEGORY_ABBR>-<ID>. Use a concise abbreviation for the category (e.g., AUTH, VAL, RES, BIL, SUP, NET, SVC, INT). - Assign the string value (e.g.,
"AX-AUTH-1001"). - Add a clear docstring explaining the specific condition that triggers this error code.
- (Optional but recommended) Consider creating a more specific exception
class inheriting from the corresponding category exception (e.g.,
class InvalidApiKeyError(AuthenticationError): ...) and assign the new error code to it.
AX_AUTH_ERROR
General authentication error. Use for issues like invalid API keys, insufficient permissions, or failed login attempts.
AX_VAL_ERROR
General validation error. Use when user-provided input fails validation checks (e.g., incorrect data type, missing required fields, invalid format.
AX_RES_ERROR
General resource error. Use for issues related to accessing or managing resources, such as a requested model being unavailable or quota limits exceeded.
AX_BIL_ERROR
General billing error. Use for problems related to billing, payments, or credits (e.g., insufficient funds, expired subscription.
AX_SUP_ERROR
General supplier error. Use when an error originates from an external supplier or third-party service integrated with aiXplain.
AX_NET_ERROR
General network error. Use for issues related to network connectivity, such as timeouts, DNS resolution failures, or unreachable services.
AX_SVC_ERROR
General service error. Use when a specific aiXplain service or endpoint is unavailable or malfunctioning (e.g., service downtime, internal component failure.
AX_INT_ERROR
General internal error. Use for unexpected server-side errors that are not covered by other categories. This often indicates a bug or an issue within the aiXplain platform itself.
__str__
def __str__() -> str
Return the string representation of the error code.
Returns:
str- The error code value as a string.
AixplainBaseException Objects
class AixplainBaseException(Exception)
Base exception class for all aiXplain exceptions.
This class serves as the foundation for all custom exceptions in the aiXplain system. It provides structured error information including categorization, severity, and additional context.
Attributes:
messagestr - Error message.categoryErrorCategory - Category of the error.severityErrorSeverity - Severity level of the error.status_codeOptional[int] - HTTP status code if applicable.detailsDict[str, Any] - Additional error context and details.retry_recommendedbool - Whether retrying the operation might succeed.error_codeOptional[ErrorCode] - Standardized error code.
__init__
def __init__(message: str,
category: ErrorCategory = ErrorCategory.UNKNOWN,
severity: ErrorSeverity = ErrorSeverity.ERROR,
status_code: Optional[int] = None,
details: Optional[Dict[str, Any]] = None,
retry_recommended: bool = False,
error_code: Optional[ErrorCode] = None)
Initialize the base exception with structured error information.
Arguments:
message- Error message describing the issue.category- Category of the error (default: UNKNOWN).severity- Severity level of the error (default: ERROR).status_code- HTTP status code if applicable.details- Additional error context and details.retry_recommended- Whether retrying the operation might succeed.error_code- Standardized error code for the exception.
__str__
def __str__() -> str
Return a string representation of the exception.
Returns:
str- Formatted string containing the exception class name, error code (if present), and error message.
to_dict
def to_dict() -> Dict[str, Any]
Convert the exception to a dictionary for serialization.
Returns:
Dict[str, Any]: Dictionary containing all exception attributes including message, category, severity, status code, details, retry recommendation, and error code.
AuthenticationError Objects
class AuthenticationError(AixplainBaseException)
Raised when authentication fails.
__init__
def __init__(message: str, **kwargs)
Initialize authentication error.
Arguments:
message- Error message describing the authentication issue.**kwargs- Additional keyword arguments passed to parent class.
ValidationError Objects
class ValidationError(AixplainBaseException)
Raised when input validation fails.
__init__
def __init__(message: str, **kwargs)
Initialize validation error.
Arguments:
message- Error message describing the validation issue.**kwargs- Additional keyword arguments passed to parent class.
AlreadyDeployedError Objects
class AlreadyDeployedError(AixplainBaseException)
Raised when attempting to deploy an asset that is already deployed.
__init__
def __init__(message: str, **kwargs)
Initialize already deployed error.
Arguments:
message- Error message describing the deployment state conflict.**kwargs- Additional keyword arguments passed to parent class.
ResourceError Objects
class ResourceError(AixplainBaseException)
Raised when a resource is unavailable.
__init__
def __init__(message: str, **kwargs)
Initialize resource error.
Arguments:
message- Error message describing the resource issue.**kwargs- Additional keyword arguments passed to parent class.
BillingError Objects
class BillingError(AixplainBaseException)
Raised when there are billing issues.
__init__
def __init__(message: str, **kwargs)
Initialize billing error.
Arguments:
message- Error message describing the billing issue.**kwargs- Additional keyword arguments passed to parent class.
SupplierError Objects
class SupplierError(AixplainBaseException)
Raised when there are issues with external suppliers.
__init__
def __init__(message: str, **kwargs)
Initialize supplier error.
Arguments:
message- Error message describing the supplier issue.**kwargs- Additional keyword arguments passed to parent class.
NetworkError Objects
class NetworkError(AixplainBaseException)
Raised when there are network connectivity issues.
__init__
def __init__(message: str, **kwargs)
Initialize network error.
Arguments:
message- Error message describing the network issue.**kwargs- Additional keyword arguments passed to parent class.
ServiceError Objects
class ServiceError(AixplainBaseException)
Raised when a service is unavailable.
__init__
def __init__(message: str, **kwargs)
Initialize service error.
Arguments:
message- Error message describing the service issue.**kwargs- Additional keyword arguments passed to parent class.
InternalError Objects
class InternalError(AixplainBaseException)
Raised when there is an internal system error.
__init__
def __init__(message: str, **kwargs)
Initialize internal error.
Arguments:
message- Error message describing the internal issue.**kwargs- Additional keyword arguments passed to parent class.
AlreadyDeployedError Objects
class AlreadyDeployedError(AixplainBaseException)
Raised when an asset is already deployed.