Last Verified: 2025-01-27
Package:
@hopx-ai/sdk on npm
Overview
The JavaScript SDK provides a comprehensive error hierarchy for handling different types of errors. All errors inherit fromHopxError.
Import
Base Error
HopxError
Base exception for all HopX SDK errors.
Properties:
message(string): Error messagecode(string, optional): Error coderequestId(string, optional): Request ID for debuggingstatusCode(number, optional): HTTP status codedetails(Record<string, any>, optional): Additional error details
API Errors
APIError
Base class for API request failures.
Inherits from: HopxError
AuthenticationError
Authentication failed (401).
Inherits from: APIError
When thrown:
- Invalid or missing API key
- Expired authentication token
NotFoundError
Resource not found (404).
Inherits from: APIError
When thrown:
- Sandbox not found
- Template not found
- File not found
ValidationError
Request validation failed (400).
Inherits from: APIError
When thrown:
- Invalid parameters
- Missing required fields
RateLimitError
Rate limit exceeded (429).
Inherits from: APIError
Properties:
retryAfter(number, optional): Seconds to wait before retrying
ResourceLimitError
Resource limit exceeded.
Inherits from: APIError
Properties:
limit(number): Resource limitcurrent(number): Current usageavailable(number): Available resources
ServerError
Server error (5xx).
Inherits from: APIError
Network Errors
NetworkError
Network communication failed.
Inherits from: HopxError
TimeoutError
Request timed out.
Inherits from: NetworkError
Error Handling Examples
Example 1: Basic Error Handling
Example 2: Specific Error Handling
Related Classes
See Also
- Types - Learn about type definitions
- 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

