@salesforce/apex-node
Version:
Salesforce JS library for Apex
64 lines • 2.14 kB
JavaScript
;
/*
* Copyright (c) 2021, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatTestErrors = formatTestErrors;
exports.getSyncDiagnostic = getSyncDiagnostic;
exports.getAsyncDiagnostic = getAsyncDiagnostic;
const i18n_1 = require("../i18n");
function formatTestErrors(error) {
const matches = error.message?.match(/\bsObject type ["'](.*?)["'] is not supported\b/);
if (matches?.[0] && matches?.[1]) {
error.message = i18n_1.nls.localize('invalidsObjectErr', [
matches[1],
error.message
]);
return error;
}
return error;
}
function getSyncDiagnostic(syncRecord) {
const diagnostic = {
exceptionMessage: syncRecord.message,
exceptionStackTrace: syncRecord.stackTrace,
className: syncRecord.stackTrace
? syncRecord.stackTrace.split('.')[1]
: undefined,
compileProblem: ''
};
const matches = syncRecord.stackTrace?.match(/(line (\d+), column (\d+))/);
if (matches) {
if (matches[2]) {
diagnostic.lineNumber = Number(matches[2]);
}
if (matches[3]) {
diagnostic.columnNumber = Number(matches[3]);
}
}
return diagnostic;
}
function getAsyncDiagnostic(asyncRecord) {
const diagnostic = {
exceptionMessage: asyncRecord.Message,
exceptionStackTrace: asyncRecord.StackTrace,
className: asyncRecord.StackTrace
? asyncRecord.StackTrace.split('.')[1]
: undefined,
compileProblem: ''
};
const matches = asyncRecord.StackTrace?.match(/(line (\d+), column (\d+))/);
if (matches) {
if (matches[2]) {
diagnostic.lineNumber = Number(matches[2]);
}
if (matches[3]) {
diagnostic.columnNumber = Number(matches[3]);
}
}
return diagnostic;
}
//# sourceMappingURL=diagnosticUtil.js.map