Skip to content

Commit bdf2b9b

Browse files
alan-agius4dgp1130
authored andcommitted
fix(@angular/cli): print schematic errors correctly
Previously, the errors were JSON stringified (https://github.com/angular/angular-cli/blob/main/packages/angular/cli/lib/cli/index.ts#L80) which caused them not to be displayed correctly. Closes #23141 (cherry picked from commit f00da00)
1 parent 4346e7e commit bdf2b9b

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

packages/angular/cli/lib/cli/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ export default async function (options: { cliArgs: string[] }) {
7777
} else if (typeof err === 'number') {
7878
// Log nothing.
7979
} else {
80-
logger.fatal('An unexpected error occurred: ' + JSON.stringify(err));
80+
logger.fatal(
81+
`An unexpected error occurred: ${'toString' in err ? err.toString() : JSON.stringify(err)}`,
82+
);
8183
}
8284

8385
return 1;

packages/angular/cli/src/command-builder/schematics-command-module.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,11 @@ export abstract class SchematicsCommandModule
321321
if (err instanceof UnsuccessfulWorkflowExecution) {
322322
// "See above" because we already printed the error.
323323
logger.fatal('The Schematic workflow failed. See above.');
324-
325-
return 1;
326324
} else {
327-
throw err;
325+
logger.fatal(err.message);
328326
}
327+
328+
return 1;
329329
} finally {
330330
unsubscribe();
331331
}

0 commit comments

Comments
 (0)