Merge pull request #2009 from Albert-Hugo/hotfix_2006

[#2006] Change to throw NacosException
This commit is contained in:
Fury Zhu 2019-11-07 16:23:56 +08:00 committed by GitHub
commit 8c104bc432
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -430,16 +430,16 @@ public class NamingProxy {
+ result.code + " msg: " + result.content);
}
public String reqAPI(String api, Map<String, String> params, List<String> servers) {
public String reqAPI(String api, Map<String, String> params, List<String> servers) throws NacosException {
return reqAPI(api, params, servers, HttpMethod.GET);
}
public String reqAPI(String api, Map<String, String> params, List<String> servers, String method) {
public String reqAPI(String api, Map<String, String> params, List<String> servers, String method) throws NacosException {
params.put(CommonParams.NAMESPACE_ID, getNamespaceId());
if (CollectionUtils.isEmpty(servers) && StringUtils.isEmpty(nacosDomain)) {
throw new IllegalArgumentException("no server available");
throw new NacosException(NacosException.INVALID_PARAM, "no server available");
}
Exception exception = new Exception();
@ -464,7 +464,7 @@ public class NamingProxy {
index = (index + 1) % servers.size();
}
throw new IllegalStateException("failed to req API:" + api + " after all servers(" + servers + ") tried: "
throw new NacosException(NacosException.SERVER_ERROR, "failed to req API:" + api + " after all servers(" + servers + ") tried: "
+ exception.getMessage());
}
@ -477,7 +477,7 @@ public class NamingProxy {
}
}
throw new IllegalStateException("failed to req API:/api/" + api + " after all servers(" + servers + ") tried: "
throw new NacosException(NacosException.SERVER_ERROR, "failed to req API:/api/" + api + " after all servers(" + servers + ") tried: "
+ exception.getMessage());
}