refactor(@angular/cli): implement structured error handling in package manager API#32029
Merged
clydin merged 1 commit intoangular:mainfrom Dec 4, 2025
Merged
Conversation
…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).
hybrist
approved these changes
Dec 4, 2025
| */ | ||
| export interface ErrorInfo { | ||
| /** A specific error code (e.g. 'E404', 'EACCES'). */ | ||
| readonly code: string; |
Contributor
There was a problem hiding this comment.
Is it worth to make this narrower than string to make it clearer what kind of error codes to expect?
Member
Author
There was a problem hiding this comment.
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.
Member
Author
|
This PR was merged into the repository. The changes were merged into the following branches:
|
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
ErrorInfointerface to represent parsed error details.PackageManagerErrorif a command fails for an unknown reason, preventing silent failures.PackageManagerDescriptor, removing hardcoded logic from the execution layer.yarn-classicparser to use verbose logs, allowing it to accurately detect and report specific HTTP status codes (e.g., 401, 403, 404, 500).