UNPKG

@magiceden/magiceden-sdk

Version:

A TypeScript SDK for interacting with Magic Eden's API across multiple chains.

77 lines (76 loc) 2.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TransactionError = exports.WalletError = exports.RateLimitError = exports.AuthenticationError = exports.NetworkError = exports.ApiError = void 0; /** * Base API error class */ class ApiError extends Error { constructor(message, status) { super(message); this.name = 'ApiError'; this.status = status; // This is needed to make instanceof work correctly in TypeScript Object.setPrototypeOf(this, ApiError.prototype); } } exports.ApiError = ApiError; /** * Network error class */ class NetworkError extends ApiError { constructor(status, statusText, data) { super(`Network error: ${status} ${statusText}`, status); this.name = 'NetworkError'; this.statusText = statusText; this.data = data; Object.setPrototypeOf(this, NetworkError.prototype); } } exports.NetworkError = NetworkError; /** * Authentication error class */ class AuthenticationError extends ApiError { constructor(message = 'Authentication failed', status = 401) { super(message, status); this.name = 'AuthenticationError'; Object.setPrototypeOf(this, AuthenticationError.prototype); } } exports.AuthenticationError = AuthenticationError; /** * Rate limit error class */ class RateLimitError extends ApiError { constructor(message = 'Rate limit exceeded', retryAfter) { super(message, 429); this.name = 'RateLimitError'; this.retryAfter = retryAfter; Object.setPrototypeOf(this, RateLimitError.prototype); } } exports.RateLimitError = RateLimitError; /** * Wallet error class */ class WalletError extends ApiError { constructor(message, status = 400) { super(message, status); this.name = 'WalletError'; Object.setPrototypeOf(this, WalletError.prototype); } } exports.WalletError = WalletError; /** * Transaction error class */ class TransactionError extends ApiError { constructor(message, txId, logs, status = 400) { super(message, status); this.name = 'TransactionError'; this.txId = txId; this.logs = logs; Object.setPrototypeOf(this, TransactionError.prototype); } } exports.TransactionError = TransactionError;