优化client错误判断

This commit is contained in:
zhouhao
2017-10-25 17:56:34 +08:00
parent 417fb08082
commit bf39fe8445

View File

@@ -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;
}