Commit 216d5658 by sikang

update

parent 0fec2ba9
......@@ -56,7 +56,7 @@ public abstract class HttpObserver<T> implements Observer<T> {
onFinish();
onSuccess(tResult);
} catch (Exception e) {
onError(Error.UNKNOW, action + " error");
onError(Error.UNKNOW, action + " - Result Exception : " + e.getMessage());
}
}
......@@ -64,29 +64,28 @@ public abstract class HttpObserver<T> implements Observer<T> {
public void onError(Throwable throwable) {
onFinish();
String msg = throwable.getMessage();
LogUtils.d("HttpObserver", action + " -> error msg : " + msg);
try {
if (throwable != null) {
if (isNetworkError(msg)) {
onError(Error.HTTP_ERROR, LibConfig.getContext().getString(R.string.text_net_error));
onError(Error.HTTP_ERROR, action + " - " + LibConfig.getContext().getString(R.string.text_net_error));
} else if (throwable instanceof HttpException) {
HttpException exception = (HttpException) throwable;
if (!isCanHandle(exception)) {
String body = exception.response().errorBody().string();
ResponseErrorBody responseErrorBody = new Gson().fromJson(body, ResponseErrorBody.class);
onError(Error.SERVER_ERROR, responseErrorBody.getMessage());
onError(Error.SERVER_ERROR, action + " - ServerException" + responseErrorBody.getMessage());
}
} else if (msg.contains("java.lang.IllegalStateException")) {
onError(Error.APP_ERROR, "Program Exception");
onError(Error.APP_ERROR, action + " - Program Exception");
} else if (msg.contains("body is null")) {
onSuccess(null);
} else {
onError(Error.UNKNOW, action + " " + msg);
onError(Error.UNKNOW, action + " - ServerException" + msg);
}
}
} catch (Exception e) {
onError(Error.APP_ERROR, "Error: " + e.getMessage());
onError(Error.APP_ERROR, action + " - Unknown Exception" + e.getMessage());
}
if (disposable != null)
disposable.dispose();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment