Skip to content
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

Service.get calls success handler even though error occured #264

Open
baranchikovaleks opened this issue Feb 26, 2020 · 0 comments
Open

Comments

@baranchikovaleks
Copy link

baranchikovaleks commented Feb 26, 2020

Hi there!

Here is a simple snippet

this.someService.get(resource_id).pipe(
  catchError(() => of(1))
).subscribe((response) => {
    console.log(response);
  },
);

In case of server error (e.g. 404 Not Found) there will be at least 2 lines printed

$some not properly built resource where is_loading === true
1

A bit re-worked example

this.someService.get(resource_id).pipe(
  catchError(() => throwError(1))
).subscribe((response) => {
    console.log(response);
  },
  error => {
    console.log(error);
  }
);

The output is the same 2 lines as above.

So we end up with handling not properly built object wihtout knowing that there was an error! That looks like a bug in the library.

My suggestion is to remove emitting a resource in before error (in case there is any) here
https://github.com/reyesoft/ngx-jsonapi/blob/v2.1/src/service.ts#L164-L165

Or at least add something that indicates that there was an error occured.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant