UNPKG

@varia-bly/variably-sdk

Version:

Official JavaScript/TypeScript SDK for Variably feature flags, experimentation, and real-time dynamic configurations

71 lines 2.36 kB
"use strict"; /** * Error classes for Variably SDK */ Object.defineProperty(exports, "__esModule", { value: true }); exports.ConfigurationError = exports.TimeoutError = exports.RateLimitError = exports.ValidationError = exports.AuthenticationError = exports.NetworkError = exports.VariablyError = void 0; class VariablyError extends Error { constructor(message, cause) { super(message); this.cause = cause; this.name = 'VariablyError'; // Maintain proper stack trace for where error was thrown if (Error.captureStackTrace) { Error.captureStackTrace(this, VariablyError); } } } exports.VariablyError = VariablyError; class NetworkError extends VariablyError { constructor(message, statusCode, url, cause) { super(message, cause); this.statusCode = statusCode; this.url = url; this.name = 'NetworkError'; } static isRetryable(statusCode) { // Retry on 5xx errors and certain 4xx errors return statusCode >= 500 || statusCode === 408 || statusCode === 429; } } exports.NetworkError = NetworkError; class AuthenticationError extends VariablyError { constructor(message, cause) { super(message, cause); this.name = 'AuthenticationError'; } } exports.AuthenticationError = AuthenticationError; class ValidationError extends VariablyError { constructor(message, field, cause) { super(message, cause); this.field = field; this.name = 'ValidationError'; } } exports.ValidationError = ValidationError; class RateLimitError extends VariablyError { constructor(message, retryAfter, cause) { super(message, cause); this.retryAfter = retryAfter; this.name = 'RateLimitError'; } } exports.RateLimitError = RateLimitError; class TimeoutError extends VariablyError { constructor(message, operation, cause) { super(message, cause); this.operation = operation; this.name = 'TimeoutError'; } } exports.TimeoutError = TimeoutError; class ConfigurationError extends VariablyError { constructor(message, parameter, cause) { super(message, cause); this.parameter = parameter; this.name = 'ConfigurationError'; } } exports.ConfigurationError = ConfigurationError; //# sourceMappingURL=errors.js.map