Last Verified: 2025-01-27
Package:
hopx-ai on PyPI
Overview
The Python SDK provides a comprehensive error hierarchy for handling different types of errors. All errors inherit fromHopxError and provide detailed error information.
Import
Base Error
HopxError
Base exception for all HopX SDK errors.
Fields:
message(str): Error messagecode(str, optional): Error coderequest_id(str, optional): Request ID for debuggingstatus_code(int, optional): HTTP status codedetails(Dict[str, Any], optional): Additional error details
API Errors
APIError
Base class for API request failures.
Inherits from: HopxError
Fields:
status_code(int): HTTP status code
AuthenticationError
Authentication failed (401).
Inherits from: APIError
When raised:
- Invalid or missing API key
- Expired authentication token
NotFoundError
Resource not found (404).
Inherits from: APIError
When raised:
- Sandbox not found
- Template not found
- File not found
ValidationError
Request validation failed (400).
Inherits from: APIError
Fields:
field(str, optional): Field that failed validation
- Invalid parameters
- Missing required fields
- Invalid data format
RateLimitError
Rate limit exceeded (429).
Inherits from: APIError
Fields:
retry_after(int, optional): Seconds to wait before retrying
- Too many requests in a time period
ResourceLimitError
Resource limit exceeded.
Inherits from: APIError
Fields:
limit(int): Resource limitcurrent(int): Current usageavailable(int): Available resourcesupgrade_url(str, optional): URL to upgrade plan
- Exceeded sandbox quota
- Insufficient resources
ServerError
Server error (5xx).
Inherits from: APIError
When raised:
- Internal server error
- Service unavailable
Network Errors
NetworkError
Network communication failed.
Inherits from: HopxError
When raised:
- Connection errors
- DNS resolution failures
TimeoutError
Request timed out.
Inherits from: NetworkError
When raised:
- Request exceeded timeout
- Operation took too long
Agent Errors
AgentError
Base error for agent operations.
Inherits from: HopxError
FileNotFoundError
File or directory not found in sandbox.
Inherits from: AgentError
Fields:
path(str): Path that was not found
FileOperationError
File operation failed.
Inherits from: AgentError
Fields:
operation(str): Operation that failed
CodeExecutionError
Code execution failed.
Inherits from: AgentError
Fields:
language(str): Language that failed
CommandExecutionError
Command execution failed.
Inherits from: AgentError
Fields:
command(str): Command that failed
DesktopNotAvailableError
Desktop automation not available in this sandbox.
Inherits from: AgentError
Fields:
missing_dependencies(List[str]): Missing dependenciesdocs_url(str, optional): Documentation URLinstall_command(str, optional): Installation command
Error Handling Examples
Example 1: Basic Error Handling
Example 2: Specific Error Handling
Example 3: Retry on Rate Limit
Related Classes
See Also
- Models - Learn about data models
- Core Concepts: Errors - Learn about error handling
Next Steps
Now that you understand error handling, explore:- Error Handling Basics - Practical error handling patterns
- Sandbox Operations - See errors in action
- API Errors - Understand API error responses
- CLI Reference - Use HopX from the command line
- Troubleshooting - Common issues and solutions

