aixplain.exceptions.types
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:
INFO
str - Informational message, not an actual error.WARNING
str - Warning that doesn't prevent operation completion.ERROR
str - Error condition that prevents operation completion.CRITICAL
str - 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:
AUTHENTICATION
str - Authentication and authorization errors.VALIDATION
str - Input validation errors.RESOURCE
str - Resource availability and access errors.BILLING
str - Billing and payment-related errors.SUPPLIER
str - External supplier and third-party service errors.NETWORK
str - Network connectivity errors.SERVICE
str - Service availability errors.INTERNAL
str - Internal system errors.AGENT
str - Agent-specific errors.UNKNOWN
str - 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
ErrorCategory
for the new error. - Determine the next available sequential ID within that category.
For example, if
AX-AUTH-1000
exists, 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:
message
str - Error message.category
ErrorCategory - Category of the error.severity
ErrorSeverity - Severity level of the error.status_code
Optional[int] - HTTP status code if applicable.details
Dict[str, Any] - Additional error context and details.retry_recommended
bool - Whether retrying the operation might succeed.error_code
Optional[ErrorCode] - Standardized error code.
__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.
ValidationError Objects
class ValidationError(AixplainBaseException)
Raised when input validation fails.
ResourceError Objects
class ResourceError(AixplainBaseException)
Raised when a resource is unavailable.
BillingError Objects
class BillingError(AixplainBaseException)
Raised when there are billing issues.
SupplierError Objects
class SupplierError(AixplainBaseException)
Raised when there are issues with external suppliers.
NetworkError Objects
class NetworkError(AixplainBaseException)
Raised when there are network connectivity issues.
ServiceError Objects
class ServiceError(AixplainBaseException)
Raised when a service is unavailable.
InternalError Objects
class InternalError(AixplainBaseException)
Raised when there is an internal system error.