UNPKG

@elusion-sdk/briq

Version:

A modern TypeScript SDK for Briq SMS API integration

66 lines 2.15 kB
export class BriqError extends Error { code; statusCode; details; constructor(message, code, statusCode, details) { super(message); this.name = this.constructor.name; this.code = code; this.statusCode = statusCode; this.details = details; if (Error.captureStackTrace) { Error.captureStackTrace(this, this.constructor); } } } export class AuthenticationError extends BriqError { constructor(message = "Authentication failed", details) { super(message, "AUTHENTICATION_ERROR", 401, details); } } export class AuthorizationError extends BriqError { constructor(message = "Insufficient permissions", details) { super(message, "AUTHORIZATION_ERROR", 403, details); } } export class ValidationError extends BriqError { constructor(message, details) { super(message, "VALIDATION_ERROR", 400, details); } } export class NotFoundError extends BriqError { constructor(resource, id) { const message = id ? `${resource} with ID '${id}' not found` : `${resource} not found`; super(message, "NOT_FOUND_ERROR", 404, { resource, id }); } } export class RateLimitError extends BriqError { constructor(message = "Rate limit exceeded", retryAfter) { super(message, "RATE_LIMIT_ERROR", 429, { retryAfter }); } } export class NetworkError extends BriqError { constructor(message = "Network error occurred", details) { super(message, "NETWORK_ERROR", undefined, details); } } export class ServerError extends BriqError { constructor(message = "Internal server error", statusCode = 500, details) { super(message, "SERVER_ERROR", statusCode, details); } } export class ConfigurationError extends BriqError { constructor(message, details) { super(message, "CONFIGURATION_ERROR", undefined, details); } } export class TimeoutError extends BriqError { constructor(timeout) { super(`Request timed out after ${timeout}ms`, "TIMEOUT_ERROR", 408, { timeout, }); } } //# sourceMappingURL=errors.js.map