Skip to main content
Version: 1.0

aixplain.exceptions.types

ErrorSeverity Objects

class ErrorSeverity(str, Enum)

[view_source]

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)

[view_source]

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)

[view_source]

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:

  1. Identify the appropriate ErrorCategory for the new error.
  2. Determine the next available sequential ID within that category. For example, if AX-AUTH-1000 exists, the next authentication-specific error could be AX-AUTH-1001.
  3. 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).
  4. Assign the string value (e.g., "AX-AUTH-1001").
  5. Add a clear docstring explaining the specific condition that triggers this error code.
  6. (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

[view_source]

Return the string representation of the error code.

Returns:

  • str - The error code value as a string.

AixplainBaseException Objects

class AixplainBaseException(Exception)

[view_source]

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

[view_source]

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]

[view_source]

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)

[view_source]

Raised when authentication fails.

ValidationError Objects

class ValidationError(AixplainBaseException)

[view_source]

Raised when input validation fails.

ResourceError Objects

class ResourceError(AixplainBaseException)

[view_source]

Raised when a resource is unavailable.

BillingError Objects

class BillingError(AixplainBaseException)

[view_source]

Raised when there are billing issues.

SupplierError Objects

class SupplierError(AixplainBaseException)

[view_source]

Raised when there are issues with external suppliers.

NetworkError Objects

class NetworkError(AixplainBaseException)

[view_source]

Raised when there are network connectivity issues.

ServiceError Objects

class ServiceError(AixplainBaseException)

[view_source]

Raised when a service is unavailable.

InternalError Objects

class InternalError(AixplainBaseException)

[view_source]

Raised when there is an internal system error.