mirror of
https://github.com/github/codeql-action.git
synced 2026-10-30 01:27:22 +00:00
Wrap JSON parsing in try/catch
This commit is contained in:
8
lib/codeql.js
generated
8
lib/codeql.js
generated
@@ -255,7 +255,13 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
||||
async getVersion() {
|
||||
let result = util.getCachedCodeQlVersion();
|
||||
if (result === undefined) {
|
||||
result = JSON.parse(await runTool(cmd, ["version", "--format=json"]));
|
||||
const output = await runTool(cmd, ["version", "--format=json"]);
|
||||
try {
|
||||
result = JSON.parse(output);
|
||||
}
|
||||
catch (err) {
|
||||
throw Error(`Invalid JSON output from \`version --format=json\`: ${output}`);
|
||||
}
|
||||
util.cacheCodeQlVersion(result);
|
||||
}
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user