wolfhoundjesse wolfhoundjesse - 1 year ago 71
Javascript Question

Is Error Considered an Emission from an Observable in RxJs?

Quick question: Will

fire off when there is an error? The docs say, "Perform a side effect for every emission on the source Observable, but return an Observable that is identical to the source." Is an error considered an emission, too?

return this.authHttp.get(url)
.do(() => console.log("I'm doing something"))
.catch(error => {
if (isDev) this.toastr.error("The panels could not be retrieved from the API.");
return this.handleEerror(error);

Answer Source

The .do() method can take an optional onError callback for handling errors:

    value => console.log("I'm doing something"),
    err   => console.error('I got an error', err.stack)

...otherwise it will just pass through the pipeline.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download