Emit Error Notification
Emit Error Notification
- Observers have an
error
method that allows you to notify subscribers of an error - Once the
error
method is called, the observable is finished and cannot emit new values, new errors, or emit a proper complete notification
new Observable((observer) => {
try {
const result = doSomething();
observer.next(result);
observer.complete();
} catch (e) {
observer.error(e);
}
});