package com.nestedworld.nestedworld.network.http.callback;

import android.accounts.NetworkErrorException;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import retrofit2.Call;
import retrofit2.Response;

public abstract class NestedWorldHttpCallback<T> implements retrofit2.Callback<T> {

    @Override
    public void onResponse(Call<T> call, Response<T> response) {
        if (response != null && response.isSuccessful()) {
            onSuccess(response);
        } else {
            onError(KIND.SERVER, response);
        }
    }

    @Override
    public void onFailure(Call<T> call, Throwable t) {
        if (t instanceof NetworkErrorException) {
            onError(KIND.NETWORK, null);
        } else {
            onError(KIND.UNEXPECTED, null);
        }
    }

    public abstract void onSuccess(@NonNull final Response<T> response);

    public abstract void onError(@NonNull final KIND errorKind, @Nullable Response<T> response);

    public enum KIND {
        NETWORK,
        UNEXPECTED,
        SERVER,
    }

}

@@ -188,16 +188,45 @@
 lable;%0A%0A
+import java.io.IOException;%0A%0A
 import r
@@ -717,16 +717,44 @@
 xception
+ %7C%7C t instanceof IOException
 ) %7B%0A    

fix issue with of error description