From 87ec15ba266436b7b99b0629beaea3e487434115 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Wed, 30 Oct 2024 09:11:06 +0000 Subject: [PATCH] fix(@angular/build): show error message when error stack is undefined Handle cases where the error stack is missing by displaying a relevant message. Closes #28740 --- .../angular/build/src/utils/server-rendering/prerender.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/angular/build/src/utils/server-rendering/prerender.ts b/packages/angular/build/src/utils/server-rendering/prerender.ts index f8796a7ac861..46ec378b6765 100644 --- a/packages/angular/build/src/utils/server-rendering/prerender.ts +++ b/packages/angular/build/src/utils/server-rendering/prerender.ts @@ -216,7 +216,9 @@ async function renderPages( } }) .catch((err) => { - errors.push(`An error occurred while prerendering route '${route}'.\n\n${err.stack}`); + errors.push( + `An error occurred while prerendering route '${route}'.\n\n${err.stack ?? err.message ?? err.code ?? err}`, + ); void renderWorker.destroy(); }); @@ -292,7 +294,9 @@ async function getAllRoutes( const { routes: extractedRoutes, warnings }: RoutersExtractorWorkerResult = await renderWorker .run({}) .catch((err) => { - errors.push(`An error occurred while extracting routes.\n\n${err.stack}`); + errors.push( + `An error occurred while extracting routes.\n\n${err.stack ?? err.message ?? err.code ?? err}`, + ); }) .finally(() => { void renderWorker.destroy();