UNPKG

@ballin-team/paysync-nubank

Version:

<h1 align="center"> <img src="https://docs.nupaybusiness.com.br/images/logotipo.png" alt="NuPay for Business" /> </h1>

32 lines (31 loc) 1.29 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.NubankApiError = void 0; const axios_1 = require("axios"); class NubankApiError extends Error { constructor(input) { var _a; let message = 'unknown error'; if (typeof input.isAuthentic === 'boolean' && !input.isAuthentic) { message = 'Unauthenticated message'; } if (input.data instanceof Error) message = input.data.message; super(message); Object.setPrototypeOf(this, NubankApiError.prototype); this.name = 'NubankApiError'; this.path = input.path; if (input.data instanceof axios_1.AxiosError) { const data = input.data; const response = (_a = data.response) === null || _a === void 0 ? void 0 : _a.data; this.status = response === null || response === void 0 ? void 0 : response.status; this.message = (response === null || response === void 0 ? void 0 : response.message) || 'unknown error'; this.details = response === null || response === void 0 ? void 0 : response.details; } else { this.details = input.data; } console.error(this); } } exports.NubankApiError = NubankApiError;