in src/main.ts [532:569]
function handleDiagnostics(diagnostics: readonly RosettaDiagnostic[], fail: boolean | 'implicit', snippetCount = 1) {
if (fail !== false) {
// Fail on any diagnostic
if (diagnostics.length > 0) {
printDiagnostics(diagnostics, process.stderr, process.stderr.isTTY);
logging.error(
[
`${diagnostics.length} diagnostics encountered in ${snippetCount} snippets`,
...(fail === true ? ["(running with '--fail')"] : []),
].join(' '),
);
process.exitCode = 1;
}
return;
}
// Otherwise fail only on strict diagnostics. If we have strict diagnostics, print only those
// (so it's very clear what is failing the build), otherwise print everything.
const strictDiagnostics = diagnostics.filter((diag) => diag.isFromStrictAssembly);
if (strictDiagnostics.length > 0) {
printDiagnostics(strictDiagnostics, process.stderr, process.stderr.isTTY);
const remaining = diagnostics.length - strictDiagnostics.length;
logging.warn(
[
`${strictDiagnostics.length} diagnostics from assemblies with 'strict' mode on`,
...(remaining > 0 ? [`(and ${remaining} more non-strict diagnostics)`] : []),
].join(' '),
);
process.exitCode = 1;
return;
}
if (diagnostics.length > 0) {
printDiagnostics(diagnostics, process.stderr, process.stderr.isTTY);
logging.warn(`${diagnostics.length} diagnostics encountered in ${snippetCount} snippets`);
}
}