UNPKG

sendrly

Version:

Official Sendrly TypeScript/JavaScript SDK - Simple, type-safe email automation for developers

29 lines (28 loc) 1.34 kB
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); }; var _SendrlyError_instances, _SendrlyError_isRetryable; /** * Custom error class for SDK errors */ export class SendrlyError extends Error { constructor(message, type, statusCode) { super(message); _SendrlyError_instances.add(this); this.name = 'SendrlyError'; this.type = type; this.statusCode = statusCode; this.retryable = __classPrivateFieldGet(this, _SendrlyError_instances, "m", _SendrlyError_isRetryable).call(this); } } _SendrlyError_instances = new WeakSet(), _SendrlyError_isRetryable = function _SendrlyError_isRetryable() { if (this.type === 'NETWORK_ERROR' || this.type === 'TIMEOUT_ERROR') { return true; } if (this.type === 'API_ERROR' && this.statusCode) { return this.statusCode >= 500 || this.statusCode === 429; } return false; };