@varia-bly/variably-sdk
Version:
Official JavaScript/TypeScript SDK for Variably feature flags, experimentation, LLM experiments with React hooks, and real-time dynamic configurations
61 lines • 1.85 kB
JavaScript
/**
* Error classes for Variably SDK
*/
export 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);
}
}
}
export 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;
}
}
export class AuthenticationError extends VariablyError {
constructor(message, cause) {
super(message, cause);
this.name = 'AuthenticationError';
}
}
export class ValidationError extends VariablyError {
constructor(message, field, cause) {
super(message, cause);
this.field = field;
this.name = 'ValidationError';
}
}
export class RateLimitError extends VariablyError {
constructor(message, retryAfter, cause) {
super(message, cause);
this.retryAfter = retryAfter;
this.name = 'RateLimitError';
}
}
export class TimeoutError extends VariablyError {
constructor(message, operation, cause) {
super(message, cause);
this.operation = operation;
this.name = 'TimeoutError';
}
}
export class ConfigurationError extends VariablyError {
constructor(message, parameter, cause) {
super(message, cause);
this.parameter = parameter;
this.name = 'ConfigurationError';
}
}
//# sourceMappingURL=errors.js.map