I want use second param (error) on my subcriber but dot not work.
Code of my Observable:
return Observable.create(obs => {
cognitoidentityserviceprovider.adminCreateUser(params, function(error, data) {
if (error) {
console.log(error);
return throwError(error || 'Server error');
} else {
console.log(data);
return obs.next(data.User);
}
});
});
my console.log(error);
is OK but after nothing (no trace).
Code of my subscriber:
this.myService.createUser(user).subscribe(
result => this.getUsers(),
error => this.errorUsersProcessor(error));
second param (error) on my subcriber never call.
From the documentation : throwError
Creates an Observable that emits no items to the Observer and immediately emits > an error notification.
So my guess here is that the throwError is emiting an Error to a new observer not the one you are subscribing to.
You could try to notify you're actual observer to emit the error doing :
obs.error(error || new Error('Server error'));
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments