Last Updated: February 25, 2016
·
3.667K
· rafaelcgo

Compare exceptions from getCause() on Java

I was trying to see what kind of retrofitError was returning and compare it if it wasn't isNetworkError. Couldn't make it work comparing directly....

Example:
if (retrofitError.isNetworkError()) {
// Do something...
} else if (retrofitError.getCause().getClass().equals(ConversionException.class)) {
// Do something...
}