- I am implementing in Android (Java).
I want to throw an appropriate error message when cannot connect to the server. (Either the server is down or there is no internet connection.)
It seems when there's no internet connection, it returns with a response with FacebookRequestError of errorCode = -1 & requestCode = -1. Is this safe to think only no internet connection throws this error? In other words, are there other errors that throws errorCode = -1 & requestCode = -1?
Request request = new Request(session, "me/friends", params, HttpMethod.GET, new Request.Callback() {
@Override
public void onCompleted(Response response) {
try {
FacebookRequestError fre = response.getError();
if(fre != null) {
int errorCode = fre.getErrorCode();
int requestCode = fre.getRequestStatusCode();
if(errorCode == -1 && requestCode == -1) {
// probably no internet connection
}
}
} catch(Exception e) {
}
}
});