UNPKG

aluvia-ts-sdk

Version:

Official Aluvia proxy management SDK for Node.js and modern JavaScript environments

74 lines 2.05 kB
/** * Custom error types for the Aluvia SDK */ /** * Base class for all Aluvia SDK errors */ export class AluviaError extends Error { constructor(message, details) { super(message); this.details = details; this.name = this.constructor.name; // Maintain proper stack trace for where our error was thrown if (Error.captureStackTrace) { Error.captureStackTrace(this, this.constructor); } } } /** * Thrown when API authentication fails */ export class AuthenticationError extends AluviaError { constructor(message = "Authentication failed", details) { super(message, details); this.code = "AUTHENTICATION_ERROR"; } } /** * Thrown when API requests fail due to network issues */ export class NetworkError extends AluviaError { constructor(message = "Network request failed", details) { super(message, details); this.code = "NETWORK_ERROR"; } } /** * Thrown when API returns an error response */ export class ApiError extends AluviaError { constructor(message = "API request failed", statusCode, details) { super(message, details); this.statusCode = statusCode; this.code = "API_ERROR"; } } /** * Thrown when input validation fails */ export class ValidationError extends AluviaError { constructor(message = "Validation failed", details) { super(message, details); this.code = "VALIDATION_ERROR"; } } /** * Thrown when a requested resource is not found */ export class NotFoundError extends AluviaError { constructor(message = "Resource not found", details) { super(message, details); this.code = "NOT_FOUND_ERROR"; } } /** * Thrown when rate limits are exceeded */ export class RateLimitError extends AluviaError { constructor(message = "Rate limit exceeded", retryAfter, details) { super(message, details); this.retryAfter = retryAfter; this.code = "RATE_LIMIT_ERROR"; } } //# sourceMappingURL=errors.js.map