Skip to content

Commit 33049e1

Browse files
committed
Handle failures in writeTemporaryDiagnosticFile
1 parent 7e304e9 commit 33049e1

2 files changed

Lines changed: 36 additions & 10 deletions

File tree

‎lib/entry-points.js‎

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

‎src/diagnostics.ts‎

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,15 @@ export function addDiagnostic(
175175
);
176176

177177
// Write the diagnostic to a temporary location.
178-
writeTemporaryDiagnosticFile(config.tempDir, language, diagnostic);
178+
writeTemporaryDiagnosticFile(logger, config.tempDir, language, diagnostic);
179179
}
180180
}
181181

182182
/** Adds a diagnostic that is not specific to any language. */
183183
export function addNoLanguageDiagnostic(
184184
config: Config | undefined,
185185
diagnostic: DiagnosticMessage,
186+
logger: Logger = getActionsLogger(),
186187
) {
187188
if (config !== undefined) {
188189
addDiagnostic(
@@ -193,8 +194,13 @@ export function addNoLanguageDiagnostic(
193194
diagnostic,
194195
);
195196
} else {
197+
logger.debug(
198+
`Writing a diagnostic not associated with any language, but we have no configuration to tell us where the database is yet.`,
199+
);
200+
196201
// Write the diagnostic to a temporary location.
197202
writeTemporaryDiagnosticFile(
203+
logger,
198204
getTemporaryDirectory(),
199205
undefined,
200206
diagnostic,
@@ -207,16 +213,24 @@ export function addNoLanguageDiagnostic(
207213
* and tracks it as a diagnostic that was written to a temporary location.
208214
*/
209215
function writeTemporaryDiagnosticFile(
216+
logger: Logger,
210217
tempDir: string,
211218
language: Language | undefined,
212219
diagnostic: DiagnosticMessage,
213220
) {
214-
// Write the diagnostic to a temporary location.
215221
const tempDiagnosticsPath = getTempDiagnosticPath(tempDir, language);
216-
const diagnosticPath = writeDiagnosticFile(tempDiagnosticsPath, diagnostic);
217222

218-
// Track the temporary file.
219-
temporaryDiagnostics.push({ path: diagnosticPath, language });
223+
try {
224+
// Write the diagnostic to a temporary location.
225+
const diagnosticPath = writeDiagnosticFile(tempDiagnosticsPath, diagnostic);
226+
227+
// Track the temporary file.
228+
temporaryDiagnostics.push({ path: diagnosticPath, language });
229+
} catch (err) {
230+
logger.warning(
231+
`Unable to write temporary diagnostic to '${tempDiagnosticsPath}': ${getErrorMessage(err)}\n\n${JSON.stringify(diagnostic)}`,
232+
);
233+
}
220234
}
221235

222236
/**

0 commit comments

Comments
 (0)