I am developing a front end which consumes JSON services provided by a server.
I happily use HTTP of Angular2 and I can catch errors via .catch()
operator.
If I find a problem related to a specific service (e.g. the service is not defined by the server) the catch()
operator receives a Response
with status 404
and I can easily manage the situation.
On the other hand, if it is the server that is completely down, the catch()
operator receives a Response with status code 200
and no specific sign or text related to the cause of the problem (which is that the whole server is down).
On the console I see that angular (http.dev.js) writes a message net::ERR_CONNECTION_REFUSED
but I do not know how to do something similar (i.e. understand what is happening and react appropriately) from within my code.
Any help would be appreciated.