mirror of
https://github.com/github/codeql-action.git
synced 2026-10-03 09:14:58 +00:00
Wrap JSON parse errors in getTracerConfigForCluster with context
This commit is contained in:
@@ -4,7 +4,7 @@ import * as path from "path";
|
||||
import { type CodeQL } from "./codeql";
|
||||
import { type Config } from "./config-utils";
|
||||
import { Logger } from "./logging";
|
||||
import { asyncSome, BuildMode } from "./util";
|
||||
import { asyncSome, BuildMode, getErrorMessage } from "./util";
|
||||
|
||||
export type TracerConfig = {
|
||||
env: { [key: string]: string };
|
||||
@@ -79,18 +79,20 @@ export async function endTracingForCluster(
|
||||
async function getTracerConfigForCluster(
|
||||
config: Config,
|
||||
): Promise<TracerConfig> {
|
||||
const tracingEnvVariables = JSON.parse(
|
||||
fs.readFileSync(
|
||||
path.resolve(
|
||||
config.dbLocation,
|
||||
"temp/tracingEnvironment/start-tracing.json",
|
||||
),
|
||||
"utf8",
|
||||
),
|
||||
const filePath = path.resolve(
|
||||
config.dbLocation,
|
||||
"temp/tracingEnvironment/start-tracing.json",
|
||||
);
|
||||
return {
|
||||
env: tracingEnvVariables,
|
||||
};
|
||||
try {
|
||||
const tracingEnvVariables = JSON.parse(fs.readFileSync(filePath, "utf8"));
|
||||
return {
|
||||
env: tracingEnvVariables,
|
||||
};
|
||||
} catch (err) {
|
||||
throw new Error(
|
||||
`Failed to parse tracing environment from '${filePath}': ${getErrorMessage(err)}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export async function getCombinedTracerConfig(
|
||||
|
||||
Reference in New Issue
Block a user