I have this question here on how Angular2+ Observable handle Http errors. When we use Angular2+ Http APIs to make requests, if the response back has error status code, and error will be thrown.
In the Angular2 Official Starter project, the error handler function to be called in:
someObs.catch(handler)
In the handler, it actually returns:
Observable.throw(...)
My question is, wouldn't this thrown new error that could potentially crash the web app? Since in Javascript if you throw some error, the web app could then unexpected behaviours.
My understanding of Observable.catch is that when some error happens, we catch it we do something else(instead of throw a new error). And since the
Observable.catch
still requires us to return an Observable, would it be a best solution to return:
Observable.empty()
as it would not emit any new value so that subscribers won't react