Closed hatimmakki closed 6 years ago
A WebbException
will be thrown.
From there, you can get the Response object via getResponse()
.
When there is no Internet connection, you typically will read 0
from getStatusCode()
.
Internally often an exception telling name resolution didn't work, but that is not mandatory, e.g. if you try to reach your server via IP-address, then another error will be wrapped inside WebbException.
How you handle this kind of error is up to you. DavidWebb
has a feature of doing retries, but I haven't tried this in case there are connection errors.
If you want to avoid running into errors caused by lack of internet connectivity, you could check that before doing a request. I suppose this could be a bit complicated, because you might deal with WiFi and mobile connectivity. And you might have to add additional privileges before being able to call network status methods.
Hi How to handle the exception that raise when no internet connection? thanks