Surface fatal CLI errors in interpret-results and run-queries (#1407)
Co-authored-by: Henry Mercer <henry.mercer@me.com>
This commit is contained in:
parent
0d9b15ca93
commit
aa0e650c6a
21 changed files with 137 additions and 85 deletions
|
|
@ -1016,7 +1016,7 @@ async function getCodeQLForCmd(
|
|||
if (querySuitePath) {
|
||||
codeqlArgs.push(querySuitePath);
|
||||
}
|
||||
await runTool(cmd, codeqlArgs);
|
||||
await toolrunnerErrorCatcher(cmd, codeqlArgs, errorMatchers);
|
||||
},
|
||||
async databaseInterpretResults(
|
||||
databasePath: string,
|
||||
|
|
@ -1059,7 +1059,12 @@ async function getCodeQLForCmd(
|
|||
codeqlArgs.push(...querySuitePaths);
|
||||
}
|
||||
// capture stdout, which contains analysis summaries
|
||||
return await runTool(cmd, codeqlArgs);
|
||||
const returnState = await toolrunnerErrorCatcher(
|
||||
cmd,
|
||||
codeqlArgs,
|
||||
errorMatchers
|
||||
);
|
||||
return returnState.stdout;
|
||||
},
|
||||
async databasePrintBaseline(databasePath: string): Promise<string> {
|
||||
const codeqlArgs = [
|
||||
|
|
@ -1247,11 +1252,16 @@ async function runTool(cmd: string, args: string[] = []) {
|
|||
const exitCode = await new toolrunner.ToolRunner(cmd, args, {
|
||||
listeners: {
|
||||
stdout: (data: Buffer) => {
|
||||
output += data.toString();
|
||||
output += data.toString("utf8");
|
||||
},
|
||||
stderr: (data: Buffer) => {
|
||||
const toRead = Math.min(maxErrorSize - error.length, data.length);
|
||||
error += data.toString("utf8", 0, toRead);
|
||||
let readStartIndex = 0;
|
||||
// If the error is too large, then we only take the last 20,000 characters
|
||||
if (data.length - maxErrorSize > 0) {
|
||||
// Eg: if we have 20,000 the start index should be 2.
|
||||
readStartIndex = data.length - maxErrorSize + 1;
|
||||
}
|
||||
error += data.toString("utf8", readStartIndex);
|
||||
},
|
||||
},
|
||||
ignoreReturnCode: true,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue