Skip to content

Commit

Permalink
Merge pull request #2009 from Albert-Hugo/hotfix_2006
Browse files Browse the repository at this point in the history
[#2006] Change to throw NacosException
  • Loading branch information
nkorange authored Nov 7, 2019
2 parents 43a30d3 + 7956acb commit 8c104bc
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -430,16 +430,16 @@ public String callServer(String api, Map<String, String> params, String curServe
+ 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();
Expand All @@ -464,7 +464,7 @@ public String reqAPI(String api, Map<String, String> params, List<String> server
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());
}

Expand All @@ -477,7 +477,7 @@ public String reqAPI(String api, Map<String, String> params, List<String> server
}
}

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());

}
Expand Down

0 comments on commit 8c104bc

Please sign in to comment.