-
-
Notifications
You must be signed in to change notification settings - Fork 40
Open
Description
Which @ngneat/query-* package(s) are the source of the bug?
query
Is this a regression?
No
Description
In my mutation function, I simulate an error:
mutationFn: () => {
return of({ data: { status: 500 } }).pipe(
tap(() => {
console.log('in tap error');
throw new Error('bla');
})
);
}
The error is caught in the onError
function, but Angular still throws it, and nothing seems to catch it.
Check the console.
Is this expected behavior, or is it a bug?
[StackBlitz example](https://stackblitz.com/edit/stackblitz-starters-vzvvph3i)
import { Component } from '@angular/core';
import { bootstrapApplication } from '@angular/platform-browser';
import { of, tap, catchError, throwError, map } from 'rxjs';
import { injectMutation, injectQuery } from '@ngneat/query';
import { CommonModule } from '@angular/common';
console.clear();
@Component({
selector: 'app-root',
imports: [CommonModule],
template: `
in app
`,
})
export class App {
#query = injectQuery();
#add = injectMutation();
add = this.#add({
mutationFn: () => {
return of({ data: { status: 500 } }).pipe(
tap(() => {
console.log('in tap error');
throw new Error('bla');
})
);
},
onSuccess: () => {
console.log('onSuccess');
},
onError: () => {
console.log('in error');
},
}).result;
ngOnInit() {
this.add().mutate({});
}
}
bootstrapApplication(App);
Metadata
Metadata
Assignees
Labels
No labels