Tamicer / Novate

A safety client by Https for android, (Android网络框架,基于Retrofit和RxJava打造的链式网络库, 支持okhttp的调用风格,又兼容Retrofit API,并支持rxJava链式操作)
Apache License 2.0
1.43k stars 268 forks source link

关于NovateException.handleException(e) 方法的调用时机的疑问 #93

Open ygc182 opened 5 years ago

ygc182 commented 5 years ago

@Override final public void onError(java.lang.Throwable e) { if (e != null && e.getMessage() != null){ LogWraper.v("Novate", e.getMessage());

    } else {
        LogWraper.v("Novate", "Throwable  || Message == Null");
    }

    if(e instanceof Throwable){ // public class Throwable extends Exception   
        LogWraper.e("Novate", "--> e instanceof Throwable");
        LogWraper.e("Novate", "--> " + e.getCause().toString());
        onError((Throwable)e); // 感觉应该在这里进行  onError(NovateException.handleException(e)) 处理
    } else { // 非Exception异常
        LogWraper.e("Novate", "e !instanceof Throwable"); 
        String detail = "";
        if (e.getCause() != null) {
            detail = e.getCause().getMessage();
        }
        LogWraper.e("Novate", "--> " + detail);

// 能走到这里,说明 e 是非Exception 异常,这里不需要再去处理的吧 onError(NovateException.handleException(e));
} onCompleted(); }

public static Throwable handleException(java.lang.Throwable e) { // 感觉这个方法设计的初衷应该是处理 Exception 这类异常 }