package com.duben.library.net.neterror;


import rx.Subscriber;

/**
 * 描述：BaseSubscriber
 * 作者：孟崔广
 * 时间：2018/1/10 17:51
 * 邮箱：mengcuiguang@cashbang.cn
 */
public abstract class BaseSubscriber<T> extends Subscriber<T> {

    @Override
    public void onCompleted() {

    }

    @Override
    final public void onError(java.lang.Throwable e) {
        if (e instanceof Throwable) {
            onError((Throwable) e);
        } else if (e instanceof Exception) {
            onError(CashException.handleException(e));
        } else {
            Throwable throwable = new Throwable(e, CashException.ERROR.UNKNOWN);
            throwable.setMessage("网络异常");
            onError(throwable);
        }
    }

    @Override
    public void onNext(T t) {

    }

    public abstract void onError(Throwable e);

}
