mirror of
https://github.com/github/codeql-action.git
synced 2026-10-03 17:41:28 +00:00
Wrap JSON parse errors in readSarifFile with context
This commit is contained in:
12
lib/entry-points.js
generated
12
lib/entry-points.js
generated
@@ -155758,7 +155758,13 @@ function getToolNames(sarifFile) {
|
||||
return Object.keys(toolNames);
|
||||
}
|
||||
function readSarifFile(sarifFilePath) {
|
||||
return JSON.parse(fs21.readFileSync(sarifFilePath, "utf8"));
|
||||
try {
|
||||
return JSON.parse(fs21.readFileSync(sarifFilePath, "utf8"));
|
||||
} catch (err) {
|
||||
throw new Error(
|
||||
`Parsing SARIF file at '${sarifFilePath}' failed: ${getErrorMessage(err)}`
|
||||
);
|
||||
}
|
||||
}
|
||||
function combineSarifFiles(sarifFiles, logger) {
|
||||
logger.info(`Loading SARIF file(s)`);
|
||||
@@ -158903,7 +158909,7 @@ var import_async = __toESM(require_async(), 1);
|
||||
var import_path7 = require("path");
|
||||
|
||||
// node_modules/archiver/lib/error.js
|
||||
var import_util35 = __toESM(require("util"), 1);
|
||||
var import_util36 = __toESM(require("util"), 1);
|
||||
var ERROR_CODES = {
|
||||
ABORTED: "archive was aborted",
|
||||
DIRECTORYDIRPATHREQUIRED: "diretory dirpath argument must be a non-empty string value",
|
||||
@@ -158928,7 +158934,7 @@ function ArchiverError(code, data) {
|
||||
this.code = code;
|
||||
this.data = data;
|
||||
}
|
||||
import_util35.default.inherits(ArchiverError, Error);
|
||||
import_util36.default.inherits(ArchiverError, Error);
|
||||
|
||||
// node_modules/archiver/lib/core.js
|
||||
var import_readable_stream2 = __toESM(require_ours(), 1);
|
||||
|
||||
@@ -3,6 +3,7 @@ import * as fs from "fs";
|
||||
import { Logger } from "../logging";
|
||||
|
||||
import * as sarif from "sarif";
|
||||
import { getErrorMessage } from "../util";
|
||||
|
||||
export type * from "sarif";
|
||||
|
||||
@@ -48,7 +49,13 @@ export function getToolNames(sarifFile: Partial<sarif.Log>): string[] {
|
||||
* @returns The resulting JSON value, cast to a SARIF `Log`.
|
||||
*/
|
||||
export function readSarifFile(sarifFilePath: string): Partial<sarif.Log> {
|
||||
return JSON.parse(fs.readFileSync(sarifFilePath, "utf8")) as sarif.Log;
|
||||
try {
|
||||
return JSON.parse(fs.readFileSync(sarifFilePath, "utf8")) as sarif.Log;
|
||||
} catch (err) {
|
||||
throw new Error(
|
||||
`Parsing SARIF file at '${sarifFilePath}' failed: ${getErrorMessage(err)}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Takes a list of paths to sarif files and combines them together,
|
||||
|
||||
Reference in New Issue
Block a user