From 589d1dff2ce8554ee53b818a98db000df7fdf4e7 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期二, 22 七月 2025 10:19:17 +0800
Subject: [PATCH] 2025年07月22日10:19:08
---
app/src/main/java/com/hdl/photovoltaic/internet/HttpClient.java | 42 +++++++++++++++++++++++++++++++++++++++---
1 files changed, 39 insertions(+), 3 deletions(-)
diff --git a/app/src/main/java/com/hdl/photovoltaic/internet/HttpClient.java b/app/src/main/java/com/hdl/photovoltaic/internet/HttpClient.java
index 9ffd9f9..075d3db 100644
--- a/app/src/main/java/com/hdl/photovoltaic/internet/HttpClient.java
+++ b/app/src/main/java/com/hdl/photovoltaic/internet/HttpClient.java
@@ -9,12 +9,15 @@
import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
import com.hdl.hdlhttp.HxHttp;
+import com.hdl.hdlhttp.HxHttpConfig;
import com.hdl.hdlhttp.utils.GsonConvert;
import com.hdl.linkpm.sdk.core.api.HDLCloudUserApi;
import com.hdl.linkpm.sdk.core.exception.HDLException;
import com.hdl.linkpm.sdk.core.interceptor.HDLSmartHeader;
import com.hdl.linkpm.sdk.core.response.HDLResponse;
import com.hdl.linkpm.sdk.utils.HDLExceptionSubmitUtils;
+import com.hdl.photovoltaic.HDLApp;
+import com.hdl.photovoltaic.R;
import com.hdl.photovoltaic.bean.HttpResponsePack;
import com.hdl.photovoltaic.config.AppConfigManage;
import com.hdl.photovoltaic.config.UserConfigManage;
@@ -62,6 +65,39 @@
}
return sHttpClient;
+ }
+
+ public static HDLException getException(HDLException e) {
+ try {
+ String str = TextUtils.isEmpty(getErrorSting(e.getCode())) ? e.getMsg() : getErrorSting(e.getCode());
+ return new HDLException(e.getCode(), str, e.getmExtra());
+ } catch (Exception exception) {
+ return e;
+ }
+ }
+
+ private static String getErrorSting(int code) {
+ try {
+ switch (code) {
+ case 1000:
+ return HDLApp.getInstance().getAppLocaleContext().getString(R.string.no_network_connection);
+ case 1001:
+ return HDLApp.getInstance().getAppLocaleContext().getString(R.string.parse_error);
+ case 1002:
+ return HDLApp.getInstance().getAppLocaleContext().getString(R.string.network_error);
+ case 1003:
+ case 1004:
+ return HDLApp.getInstance().getAppLocaleContext().getString(R.string.ssl_error);
+ case 1005:
+ return HDLApp.getInstance().getAppLocaleContext().getString(R.string.timeout_error);
+ case 4:
+ return HDLApp.getInstance().getAppLocaleContext().getString(R.string.signature_error_log_in_again);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return "";
}
/**
@@ -140,7 +176,7 @@
public void onFailure(HDLException e) {
HDLExceptionSubmitUtils.submit(requestUrl, "", e);
if (callBack != null) {
- callBack.onFailure(e);
+ callBack.onFailure(getException(e));
HdlLogLogic.print("http---鍥炲---" + requestUrl + "\r\n" + "\"{code=\"" + e.getCode() + "," + "\"message=\"" + e.getMsg() + "}", isAddToMemory);
}
}
@@ -175,7 +211,7 @@
public void onFailure(HDLException e) {
HDLExceptionSubmitUtils.submit(requestUrl, body, e);
if (callBack != null) {
- callBack.onFailure(e);
+ callBack.onFailure(getException(e));
// HdlLogLogic.print("http---鍥炲---" + requestUrl + "\r\n" + "\"{code=\"" + e.getCode() + "," + "\"message=\"" + e.getMsg() + "}", isAddToMemory);
}
}
@@ -211,7 +247,7 @@
public void onFailure(HDLException e) {
HDLExceptionSubmitUtils.submit(requestUrl, body, e);
if (callBack != null) {
- callBack.onFailure(e);
+ callBack.onFailure(getException(e));
// HdlLogLogic.print("http---鍥炲---" + requestUrl + "\r\n" + "\"{code=\"" + e.getCode() + "," + "\"message=\"" + e.getMsg() + "}", isAddToMemory);
}
}
--
Gitblit v1.8.0