I think you need to have a retrofit exception in the catch.
catch (RetrofitError error) {
methodToDeterminErrorType(error);
}
The RetroFitError
is a generic runtime exception. Once it hits the catch block you can actually verify what kind of a error was actually thrown by retrofit. Retrofit has a method isNetworkError()
which is what you are probably looking for.
So you can basically do something like this:
methodToDetermineErrorType(RetroFitError error) {
if (error.isNetworkType()) {
// show a toast
}
}
Hope this helps.