From 0c89bf11bcddd39b5193bb19e28399648c59a2b8 Mon Sep 17 00:00:00 2001
From: nilupeng <qingingrunt2010@qq.com>
Date: Sat, 29 Jan 2022 11:04:25 +0000
Subject: [PATCH] 登录界面及接口
---
app/src/main/java/com/runt/open/mvvm/retrofit/observable/HttpObserver.java | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/app/src/main/java/com/runt/open/mvvm/retrofit/observable/HttpObserver.java b/app/src/main/java/com/runt/open/mvvm/retrofit/observable/HttpObserver.java
index 7024299..3a4ac2c 100644
--- a/app/src/main/java/com/runt/open/mvvm/retrofit/observable/HttpObserver.java
+++ b/app/src/main/java/com/runt/open/mvvm/retrofit/observable/HttpObserver.java
@@ -1,5 +1,6 @@
package com.runt.open.mvvm.retrofit.observable;
+import android.accounts.NetworkErrorException;
import android.util.Log;
import androidx.annotation.NonNull;
@@ -41,14 +42,16 @@
Log.i("subscribe","onError");
try {
- Log.e(TAG,this.getClass().getSimpleName()+" "+throwable.getMessage());
+ Log.e(TAG,this.getClass().getSimpleName()+" mes:"+throwable.getMessage());
Class<M> entityClass = (Class<M>) ((ParameterizedType) this.getClass().getGenericSuperclass()).getActualTypeArguments()[0];
M t = entityClass.newInstance();//实例化一个泛型
t.code = 410;
if( throwable instanceof SocketTimeoutException){
t.msg = "服务请求超时,请稍候再试";//设置错误信息
- }else{
+ }else if( throwable instanceof NetworkErrorException){
t.msg = "网络连接不畅,请检查您的网络设置";//设置错误信息
+ }else{
+ t.msg = throwable.getMessage();//设置错误信息
}
resultLive.setValue(t);
} catch (ClassCastException e) {
--
Gitblit v1.9.1