UNPKG

neverbounce

Version:

An API wrapper for the NeverBounce API

40 lines (39 loc) 1.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * NeverBounce API Error class */ class _Error extends Error { /** * Error constructor * @param type Error type * @param message Error message */ constructor(type, message) { super(message || 'General Error'); this.name = 'NeverBounce Error'; this.type = type || 'GeneralError'; this.message = message || 'General Error'; // Maintains proper stack trace for where our error was thrown (only available on V8) if (Error.captureStackTrace) { Error.captureStackTrace(this, _Error); } } } /** * Error type constants */ _Error.AuthError = 'AuthError'; _Error.BadReferrerError = 'BadReferrerError'; _Error.GeneralError = 'GeneralError'; // Fallback error _Error.ThrottleError = 'ThrottleError'; /** * Error lookup table */ _Error._lut = { 'general_failure': _Error.GeneralError, // Fallback error 'auth_failure': _Error.AuthError, 'bad_referrer': _Error.BadReferrerError, 'throttle_triggered': _Error.ThrottleError, }; exports.default = _Error;