modem-pay
Version:
A TypeScript SDK for integrating with the Modem Pay payment gateway, enabling seamless payment processing and financial services in your applications.
22 lines (21 loc) • 847 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getErrorMessage = void 0;
const getErrorMessage = (err) => {
var _a, _b, _c, _d;
const { response } = err;
if (response) {
const { data, status } = response;
if (data) {
return {
statusCode: (_a = err === null || err === void 0 ? void 0 : err.statusCode) !== null && _a !== void 0 ? _a : status,
message: (_b = data.message) !== null && _b !== void 0 ? _b : "An error occurred.",
};
}
}
return {
statusCode: (_c = err === null || err === void 0 ? void 0 : err.statusCode) !== null && _c !== void 0 ? _c : 500,
message: (_d = err.message) !== null && _d !== void 0 ? _d : "An error occurred.",
};
};
exports.getErrorMessage = getErrorMessage;