Skip to content

fix(@angular/cli): gracefully handle package manager errors in command handler#33462

Open
alan-agius4 wants to merge 1 commit into
angular:mainfrom
alan-agius4:fix/error-logging
Open

fix(@angular/cli): gracefully handle package manager errors in command handler#33462
alan-agius4 wants to merge 1 commit into
angular:mainfrom
alan-agius4:fix/error-logging

Conversation

@alan-agius4

Copy link
Copy Markdown
Collaborator

Catch PackageManagerError in the global CommandModule handler and gracefully log the installation failure message along with the process output (stdout/stderr) using logger.fatal.

This ensures that any package manager error thrown during the execution of a command is reported cleanly to the terminal and sets the exit code to 1.

@alan-agius4 alan-agius4 requested a review from clydin June 25, 2026 13:12
@alan-agius4 alan-agius4 added target: patch This PR is targeted for the next patch release action: review The PR is still awaiting reviews from at least one requested reviewer labels Jun 25, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request centralizes the error handling for PackageManagerError by moving the catch block from the individual AddCommandModule to the base CommandModule handler, while also simplifying logger usage and autocompletion setup. The review feedback suggests improving the formatting of the logged error message in CommandModule to only append the 'Output' section if stdout or stderr actually contains content, preventing empty output lines.

Comment thread packages/angular/cli/src/command-builder/command-module.ts
…d handler

Catch `PackageManagerError` in the global `CommandModule` handler and gracefully log the installation failure message along with the process output (stdout/stderr) using `logger.fatal`.

This ensures that any package manager error thrown during the execution of a command is reported cleanly to the terminal and sets the exit code to 1.
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/cli target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants