Thanks to visit codestin.com
Credit goes to github.com

Skip to content

refactor(core): getting resource value throws an error instead of returning undefined #60271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

Humberd
Copy link
Member

@Humberd Humberd commented Mar 7, 2025

When there is an underlying error state it would not be possible to swallow the error with:

computed(() => res.value()?.inner);

@pullapprove pullapprove bot requested a review from atscott March 7, 2025 13:30
@angular-robot angular-robot bot added the area: core Issues related to the framework runtime label Mar 7, 2025
@ngbot ngbot bot added this to the Backlog milestone Mar 7, 2025
@atscott atscott requested review from alxhub and removed request for atscott March 7, 2025 17:15
@Humberd Humberd force-pushed the value-throw-on-error-state branch 6 times, most recently from ada5ed0 to 2594a2c Compare March 18, 2025 12:14
@Humberd Humberd force-pushed the value-throw-on-error-state branch 4 times, most recently from 946fdad to e652c69 Compare March 21, 2025 16:01
@Humberd
Copy link
Member Author

Humberd commented Mar 21, 2025

We would like to merge it after #60272 since both of these touch error handling.

@Humberd Humberd requested a review from alxhub March 21, 2025 16:10
@@ -66,7 +66,7 @@ export enum ResourceStatus {
*/
export interface Resource<T> {
/**
* The current value of the `Resource`, or `undefined` if there is no current value.
* The current value of the `Resource`, or throws an error if there is no current value.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* The current value of the `Resource`, or throws an error if there is no current value.
* The current value of the `Resource`, or throws an error if the resource is in an error state.

@@ -186,8 +186,8 @@ export interface BaseResourceOptions<T, R> {
request?: () => R;

/**
* The value which will be returned from the resource when a server value is unavailable, such as
* when the resource is still loading, or in an error state.
* The value which will be returned from the resource when a server value is unavailable and
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* The value which will be returned from the resource when a server value is unavailable and
* The value which will be returned from the resource when a server value is unavailable, such as
* when the resource is still loading.

@alxhub alxhub added the target: major This PR is targeted for the next major release label Mar 21, 2025
@Humberd Humberd force-pushed the value-throw-on-error-state branch from e652c69 to c186fde Compare March 28, 2025 12:50
…efined

When there is an underlying error state it would not be possible to swallow the error with:
`computed(() => res.value()?.inner);`
@Humberd Humberd force-pushed the value-throw-on-error-state branch from c186fde to 3102ba7 Compare March 28, 2025 16:27
@pullapprove pullapprove bot requested a review from devversion March 28, 2025 16:27
@Humberd
Copy link
Member Author

Humberd commented Mar 28, 2025

Close in favour of #60610

@Humberd Humberd closed this Mar 28, 2025
@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 Apr 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: core Issues related to the framework runtime target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants