Include mkdirSync in try/catch

This commit is contained in:
Michael B. Gale 2023-10-05 13:48:56 +01:00
parent a144bf5d7f
commit 3b2fee487e
No known key found for this signature in database
GPG key ID: FF5E2765BD00628F
3 changed files with 12 additions and 12 deletions

View file

@ -93,15 +93,15 @@ export function addDiagnostic(
"codeql-action",
);
// Create the directory if it doesn't exist yet.
mkdirSync(diagnosticsPath, { recursive: true });
const jsonPath = path.resolve(
diagnosticsPath,
`codeql-action-${diagnostic.timestamp}.json`,
);
try {
// Create the directory if it doesn't exist yet.
mkdirSync(diagnosticsPath, { recursive: true });
const jsonPath = path.resolve(
diagnosticsPath,
`codeql-action-${diagnostic.timestamp}.json`,
);
writeFileSync(jsonPath, JSON.stringify(diagnostic));
} catch (err) {
logger.warning(`Unable to write diagnostic message to database: ${err}`);