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

Skip to content

fix(core): fix "resource returned an error that's not an Error instance" for observables that produce HttpErrorResponse inside the rxResource signal #62110

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

TheYoungBeast
Copy link

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.dev application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

RxResource signals were intended to work with the RxJs Observables.
Those are often encapsulated inside the service layer or produced as a by-product by the HttpClient.
Currently, rxResource throws an Error described in the issues below, even though HttpErrorResponse implements the Error interface.
This PR addresses the issue for the rxResource signals.

Issue Number: #62099, #61861

What is the new behavior?

No longer throws an error "Resource returned an error that's not an Error instance".
Successfully returns the intended value by error() signal.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

…ce" for observables that produce HttpErrorResponse inside the rxResource signal (angular#62099) (related to angular#61861)
@angular-robot angular-robot bot added the area: core Issues related to the framework runtime label Jun 18, 2025
@ngbot ngbot bot added this to the Backlog milestone Jun 18, 2025
@@ -15,6 +15,7 @@ ng_project(
),
interop_deps = [
"//packages/core",
"//packages/common/http",
Copy link
Member

Choose a reason for hiding this comment

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

Dependency wise, the rxjs-interop should not depend on common/http.

Comment on lines +30 to +32
if (error instanceof HttpErrorResponse) {
return error;
}
Copy link
Member

Choose a reason for hiding this comment

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

This won't fix any other observable that throw an instance that isn't an error.

Copy link
Author

Choose a reason for hiding this comment

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

@JeanMeche I'm aware of that, and I believe that's the point. error() signal returns value of type Error. Consider HttpErrorResponse to be a "built-in" type and should be fully supported, especially given that it implements the Error interface.
My PR addresses the issue for the observables produced by HttpClient, which, in my opinion, is a good step in improving the API.
To support all types of Errors, I believe the API should be rethought and might be addressed in further PRs upon agreeing on the details.

Copy link
Member

Choose a reason for hiding this comment

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

I'll run some tests with #62111

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: core Issues related to the framework runtime
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants