diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/net/NamingProxy.java b/client/src/main/java/com/alibaba/nacos/client/naming/net/NamingProxy.java index ea38d8862..1208d5f0e 100644 --- a/client/src/main/java/com/alibaba/nacos/client/naming/net/NamingProxy.java +++ b/client/src/main/java/com/alibaba/nacos/client/naming/net/NamingProxy.java @@ -430,16 +430,16 @@ public class NamingProxy { + result.code + " msg: " + result.content); } - public String reqAPI(String api, Map params, List servers) { + public String reqAPI(String api, Map params, List servers) throws NacosException { return reqAPI(api, params, servers, HttpMethod.GET); } - public String reqAPI(String api, Map params, List servers, String method) { + public String reqAPI(String api, Map params, List 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()); }