mirror of
https://github.com/hs-web/hsweb-framework.git
synced 2026-06-20 23:36:07 +08:00
优化client错误判断
This commit is contained in:
@@ -44,19 +44,24 @@ public class HswebResponseJudgeSupport implements ResponseJudgeForProviderDefini
|
||||
if (!result.trim().startsWith("{")) {
|
||||
return null;
|
||||
}
|
||||
JSONObject jsonRes = JSON.parseObject(result);
|
||||
Integer status = jsonRes.getInteger("status");
|
||||
if (status == null && response.status() == 200) {
|
||||
return null;
|
||||
}
|
||||
if (status != null) {
|
||||
if (status == 200) {
|
||||
try {
|
||||
JSONObject jsonRes = JSON.parseObject(result);
|
||||
if (jsonRes.size() > 5) return null;
|
||||
Integer status = jsonRes.getInteger("status");
|
||||
if (status == null && response.status() == 200) {
|
||||
return null;
|
||||
}
|
||||
return ErrorType.fromCode(status).orElse(ErrorType.OTHER);
|
||||
}
|
||||
if (jsonRes.get("message") != null) {
|
||||
return ErrorType.valueOf(jsonRes.getString("message"));
|
||||
if (status != null) {
|
||||
if (status == 200) {
|
||||
return null;
|
||||
}
|
||||
return ErrorType.fromCode(status).orElse(ErrorType.OTHER);
|
||||
}
|
||||
if (jsonRes.get("message") != null) {
|
||||
return ErrorType.valueOf(jsonRes.getString("message"));
|
||||
}
|
||||
} catch (Exception ignore) {
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user