"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseSalesforceError = exports.isSalesforceError = void 0;
const isSalesforceError = (error) => {
    return (typeof error === 'object' &&
        error !== null &&
        'response' in error &&
        typeof error.response === 'object' &&
        error.response !== null &&
        Array.isArray(error.response.data) &&
        error.response.data.length > 0 &&
        'errorCode' in error.response.data[0] &&
        'message' in error.response.data[0]);
};
exports.isSalesforceError = isSalesforceError;
const parseSalesforceError = (error) => {
    var _a;
    const category = 'BAD_REQUEST';
    const salesforceError = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data[0];
    const message = `${String(salesforceError === null || salesforceError === void 0 ? void 0 : salesforceError.errorCode)}: ${String(salesforceError === null || salesforceError === void 0 ? void 0 : salesforceError.message)}`;
    return {
        date: new Date().toISOString(),
        text: {
            en: message,
        },
        error: {
            category,
            message,
        },
    };
};
exports.parseSalesforceError = parseSalesforceError;
//# sourceMappingURL=errors.js.map