Skip to content

Conversation

@clydin
Copy link
Member

@clydin clydin commented Dec 4, 2025

This commit introduces a structured error handling system into the package manager abstraction. Previously, the system treated most command failures generically, often assuming a package was simply "not found." This could mask the true root cause of issues such as network failures, registry authentication errors, or unexpected changes in a package manager's output.

The new implementation enhances diagnostics and provides clearer, more actionable error messages by:

  • Introducing a standardized ErrorInfo interface to represent parsed error details.
  • Adding dedicated parsers to extract structured error information (JSON or text-based) from the stderr of npm, yarn, pnpm, and bun.
  • Making the core execution logic stricter. It now re-throws the original PackageManagerError if a command fails for an unknown reason, preventing silent failures.
  • Abstracting the "package not found" check into the PackageManagerDescriptor, removing hardcoded logic from the execution layer.
  • Improving the yarn-classic parser to use verbose logs, allowing it to accurately detect and report specific HTTP status codes (e.g., 401, 403, 404, 500).

…e manager API

This commit introduces a structured error handling system into the package manager abstraction. Previously, the system treated most command failures generically, often assuming a package was simply "not found." This could mask the true root cause of issues such as network failures, registry authentication errors, or unexpected changes in a package manager's output.

The new implementation enhances diagnostics and provides clearer, more actionable error messages by:
- Introducing a standardized `ErrorInfo` interface to represent parsed error details.
- Adding dedicated parsers to extract structured error information (JSON or text-based) from the stderr of npm, yarn, pnpm, and bun.
- Making the core execution logic stricter. It now re-throws the original `PackageManagerError` if a command fails for an unknown reason, preventing silent failures.
- Abstracting the "package not found" check into the `PackageManagerDescriptor`, removing hardcoded logic from the execution layer.
- Improving the `yarn-classic` parser to use verbose logs, allowing it to accurately detect and report specific HTTP status codes (e.g., 401, 403, 404, 500).
@clydin clydin added the target: minor This PR is targeted for the next minor release label Dec 4, 2025
@clydin clydin marked this pull request as ready for review December 4, 2025 17:27
*/
export interface ErrorInfo {
/** A specific error code (e.g. 'E404', 'EACCES'). */
readonly code: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it worth to make this narrower than string to make it clearer what kind of error codes to expect?

Copy link
Member Author

Choose a reason for hiding this comment

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

They don't seem to be particularly consistent, unfortunately. Sometimes its a number, an HTTP status code, a Node.js error code, or even a package manager specific one.

@clydin clydin added the action: merge The PR is ready for merge by the caretaker label Dec 4, 2025
@clydin clydin merged commit 69b2be8 into angular:main Dec 4, 2025
38 checks passed
@clydin
Copy link
Member Author

clydin commented Dec 4, 2025

This PR was merged into the repository. The changes were merged into the following branches:

@clydin clydin deleted the package-managers/error-handling branch December 4, 2025 18:22
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jan 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants