Skip to content

Commit 26f5c5e

Browse files
committed
Improve logging and error handling in logTemporaryDiagnostics
1 parent c3f2a34 commit 26f5c5e

2 files changed

Lines changed: 25 additions & 8 deletions

File tree

‎lib/entry-points.js‎

Lines changed: 12 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/diagnostics.ts‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,14 +303,23 @@ function writeDiagnostic(
303303
export function logTemporaryDiagnostics(action: ActionState<["Logger"]>) {
304304
const num = temporaryDiagnostics.length;
305305

306-
if (num > 0) {
307-
action.logger.warning(
308-
`${num} diagnostic(s) could not be written to the database and will not appear on the Tool Status Page.`,
306+
if (num > 0 && action.logger.isDebug()) {
307+
action.logger.startGroup("Diagnostics in temporary location");
308+
action.logger.debug(
309+
`${num} diagnostic(s) were not moved to the database and remain in the temporary directory.`,
309310
);
310311

311312
for (const temporary of temporaryDiagnostics) {
312-
action.logger.debug(fs.readFileSync(temporary.path, "utf-8"));
313+
try {
314+
action.logger.debug(fs.readFileSync(temporary.path, "utf-8"));
315+
} catch (err) {
316+
action.logger.debug(
317+
`Failed to read diagnostics from temporary location at '${temporary.path}': ${getErrorMessage(err)}`,
318+
);
319+
}
313320
}
321+
322+
action.logger.endGroup();
314323
}
315324
}
316325

0 commit comments

Comments
 (0)