Skip to content

Commit

Permalink
fix(@angular/cli): print schematic errors correctly
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
alan-agius4 authored and dgp1130 committed May 17, 2022
1 parent 4346e7e commit bdf2b9b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion packages/angular/cli/lib/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ export default async function (options: { cliArgs: string[] }) {
} else if (typeof err === 'number') {
// Log nothing.
} else {
logger.fatal('An unexpected error occurred: ' + JSON.stringify(err));
logger.fatal(
`An unexpected error occurred: ${'toString' in err ? err.toString() : JSON.stringify(err)}`,
);
}

return 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,11 @@ export abstract class SchematicsCommandModule
if (err instanceof UnsuccessfulWorkflowExecution) {
// "See above" because we already printed the error.
logger.fatal('The Schematic workflow failed. See above.');

return 1;
} else {
throw err;
logger.fatal(err.message);
}

return 1;
} finally {
unsubscribe();
}
Expand Down

0 comments on commit bdf2b9b

Please sign in to comment.