本文整理汇总了Java中com.example.gs.mvpdemo.exception.ErrorType类的典型用法代码示例。如果您正苦于以下问题:Java ErrorType类的具体用法?Java ErrorType怎么用?Java ErrorType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ErrorType类属于com.example.gs.mvpdemo.exception包,在下文中一共展示了ErrorType类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: call
import com.example.gs.mvpdemo.exception.ErrorType; //导入依赖的package包/类
@Override
public Observable<T> call(Observable<BaseHttpResult<T>> responseObservable) {
return responseObservable.map(new Func1<BaseHttpResult<T>, T>() {
@Override
public T call(BaseHttpResult<T> httpResult) {
if (httpResult == null)
throw new ServerException(ErrorType.EMPTY_BEAN, "解析对象为空");
LogUtils.e(TAG, httpResult.toString());
if (httpResult.getStatus() != ErrorType.SUCCESS)
throw new ServerException(httpResult.getStatus(), httpResult.getMessage());
return httpResult.getData();
}
}).onErrorResumeNext(new Func1<Throwable, Observable<? extends T>>() {
@Override
public Observable<? extends T> call(Throwable throwable) {
//ExceptionEngine为处理异常的驱动器
throwable.printStackTrace();
return Observable.error(ExceptionEngine.handleException(throwable));
}
});
}
示例2: call
import com.example.gs.mvpdemo.exception.ErrorType; //导入依赖的package包/类
@Override
public Observable<T> call(Observable<BaseHttpResult<T>> responseObservable) {
return responseObservable.map(new Func1<BaseHttpResult<T>, T>() {
@Override
public T call(BaseHttpResult<T> httpResult) {
if (httpResult == null)
throw new ServerException(ErrorType.EMPTY_BEAN, "解析对象为空");
LogUtils.e(TAG, httpResult.toString());
if (httpResult.getStatus() != ErrorType.SUCCESS)
throw new ServerException(httpResult.getStatus(), httpResult.getMessage());
return httpResult.getData();
}
}).onErrorResumeNext(new Func1<Throwable, Observable<? extends T>>() {
@Override
public Observable<? extends T> call(Throwable throwable) {
//ExceptionEngine为处理异常的驱动器throwable
throwable.printStackTrace();
return Observable.error(ExceptionEngine.handleException(throwable));
}
});
}