Throw a UserError when MissingTokenException is detected

This error should not contribute to our internal failure count.
This commit is contained in:
Andrew Eisenberg
2022-04-04 11:50:33 -07:00
parent f090899ed0
commit 08ef5fcc98
3 changed files with 10 additions and 8 deletions
Generated
+5 -4
View File
@@ -47,7 +47,7 @@ async function initConfig(languagesInput, queriesInput, packsInput, configFile,
}
exports.initConfig = initConfig;
async function runInit(codeql, config, sourceRoot, processName, processLevel) {
var _a, _b;
var _a, _b, _c;
fs.mkdirSync(config.dbLocation, { recursive: true });
try {
if (await (0, util_1.codeQlVersionAbove)(codeql, codeql_1.CODEQL_VERSION_NEW_TRACING)) {
@@ -62,15 +62,16 @@ async function runInit(codeql, config, sourceRoot, processName, processLevel) {
}
}
catch (e) {
// Handle the situation where init is called twice
// for the same database in the same job.
if (e instanceof Error &&
((_a = e.message) === null || _a === void 0 ? void 0 : _a.includes("Refusing to create databases")) &&
e.message.includes("exists and is not an empty directory.")) {
// Handle the situation where init is called twice
// for the same database in the same job.
throw new util.UserError(`Is the "init" action called twice in the same job? ${e.message}`);
}
else if (e instanceof Error &&
((_b = e.message) === null || _b === void 0 ? void 0 : _b.includes("is not compatible with this CodeQL CLI"))) {
(((_b = e.message) === null || _b === void 0 ? void 0 : _b.includes("is not compatible with this CodeQL CLI")) ||
((_c = e.message) === null || _c === void 0 ? void 0 : _c.includes("eventual cause: MissingTokenException")))) {
throw new util.UserError(e.message);
}
else {