Skip to content

Commit 2002a78

Browse files
authored
feat(graph): log errors in console in graph watch mode (#23136)
1 parent 0fbd2f8 commit 2002a78

File tree

1 file changed

+30
-3
lines changed
  • packages/nx/src/command-line/graph

1 file changed

+30
-3
lines changed

packages/nx/src/command-line/graph/graph.ts

+30-3
Original file line numberDiff line numberDiff line change
@@ -300,16 +300,28 @@ export async function generateGraph(
300300
sourceMaps = projectGraphAndSourceMaps.sourceMaps;
301301
} catch (e) {
302302
if (e instanceof ProjectGraphError) {
303-
output.warn({
304-
title: 'Failed to process project graph. Showing partial graph.',
305-
});
306303
rawGraph = e.getPartialProjectGraph();
307304
sourceMaps = e.getPartialSourcemaps();
308305

309306
isPartial = true;
310307
}
311308
if (!rawGraph) {
312309
handleProjectGraphError({ exitOnError: true }, e);
310+
} else {
311+
const errors = e.getErrors();
312+
if (errors?.length > 0) {
313+
errors.forEach((e) => {
314+
output.error({
315+
title: e.message,
316+
bodyLines: [e.stack],
317+
});
318+
});
319+
}
320+
output.warn({
321+
title: `${
322+
errors?.length > 1 ? `${errors.length} errors` : `An error`
323+
} occured while processing the project graph. Showing partial graph.`,
324+
});
313325
}
314326
}
315327
let prunedGraph = pruneExternalNodes(rawGraph);
@@ -708,6 +720,21 @@ function createFileWatcher() {
708720
currentProjectGraphClientResponse.hash &&
709721
sourceMapResponse
710722
) {
723+
if (projectGraphClientResponse.errors?.length > 0) {
724+
projectGraphClientResponse.errors.forEach((e) => {
725+
output.error({
726+
title: e.message,
727+
bodyLines: [e.stack],
728+
});
729+
});
730+
output.warn({
731+
title: `${
732+
projectGraphClientResponse.errors.length > 1
733+
? `${projectGraphClientResponse.errors.length} errors`
734+
: `An error`
735+
} occured while processing the project graph. Showing partial graph.`,
736+
});
737+
}
711738
output.note({ title: 'Graph changes updated.' });
712739

713740
currentProjectGraphClientResponse = projectGraphClientResponse;

0 commit comments

Comments
 (0)