[13.1.x] refactor: make RuntimeError class reusable across packages#44652
Closed
AndrewKushnir wants to merge 3 commits intoangular:13.1.xfrom
Closed
[13.1.x] refactor: make RuntimeError class reusable across packages#44652AndrewKushnir wants to merge 3 commits intoangular:13.1.xfrom
AndrewKushnir wants to merge 3 commits intoangular:13.1.xfrom
Conversation
…4398) This commit updates the code around the `RuntimeError` class to make it more reusable between packages (currently it's only usable inside the `core` package). Specifically: - the error formatting logic was updated to handle cases when there is no error message provided - there is no special Set that contains a set of error codes for which we have guides on angular.io. Instead, this is now encoded into the error code itself (making such codes negative integers). Having a separate Set makes it non-tree-shakable, which we want to avoid. This change should allow to employ the `RuntimeError` class in other packages to further standardize this subsystem and make the errors thrown by the framework consistent. As a part of the refactoring, the `common` package code was also updated to follow the same logic as `core`, since the `RuntimeError` class was used there as well. PR Close angular#44398
This commit moves some logic to make the location of runtime error codes consistent across packages. Now all error codes are located in `packages/core/src/errors.ts` file. PR Close angular#44398
This commit performs some refactoring of the AbstractControl-based classes to employ shared `RuntimeError` class and also updates the code to avoid duplication and improve minification. PR Close angular#44398
1eb59fd to
3fd06ac
Compare
Contributor
Author
ramthir
reviewed
Jan 7, 2022
| */ | ||
| export const enum RuntimeErrorCode { | ||
| // Change Detection Errors | ||
| EXPRESSION_CHANGED_AFTER_CHECKED = -100, |
Contributor
There was a problem hiding this comment.
When do we use error codes with negative values?
Contributor
Author
There was a problem hiding this comment.
See comment above:
* Note: the minus sign denotes the fact that a particular code has a detailed guide on
* angular.io. This extra annotation is needed to avoid introducing a separate set to store
* error codes which have guides, which might leak into runtime code.
Contributor
|
This PR was merged into the repository by commit d252cff. |
atscott
pushed a commit
that referenced
this pull request
Jan 7, 2022
…44652) This commit updates the code around the `RuntimeError` class to make it more reusable between packages (currently it's only usable inside the `core` package). Specifically: - the error formatting logic was updated to handle cases when there is no error message provided - there is no special Set that contains a set of error codes for which we have guides on angular.io. Instead, this is now encoded into the error code itself (making such codes negative integers). Having a separate Set makes it non-tree-shakable, which we want to avoid. This change should allow to employ the `RuntimeError` class in other packages to further standardize this subsystem and make the errors thrown by the framework consistent. As a part of the refactoring, the `common` package code was also updated to follow the same logic as `core`, since the `RuntimeError` class was used there as well. PR Close #44398 PR Close #44652
atscott
pushed a commit
that referenced
this pull request
Jan 7, 2022
atscott
pushed a commit
that referenced
this pull request
Jan 7, 2022
|
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 PR is a patch-only version of #44398 (there was a minor merge conflict).