#869 Clarify exception message

This commit is contained in:
nkorange 2019-03-06 11:59:15 +08:00
parent 160f4f840b
commit c4ad0888e0
2 changed files with 7 additions and 18 deletions

View File

@ -35,6 +35,7 @@ public class NacosException extends Exception {
} }
public NacosException(int errCode, String errMsg) { public NacosException(int errCode, String errMsg) {
super(errMsg);
this.errCode = errCode; this.errCode = errCode;
this.errMsg = errMsg; this.errMsg = errMsg;
} }

View File

@ -18,7 +18,6 @@ package com.alibaba.nacos.client.naming.net;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import com.alibaba.nacos.api.common.Constants;
import com.alibaba.nacos.api.exception.NacosException; import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.api.naming.CommonParams; import com.alibaba.nacos.api.naming.CommonParams;
import com.alibaba.nacos.api.naming.pojo.Instance; import com.alibaba.nacos.api.naming.pojo.Instance;
@ -28,23 +27,14 @@ import com.alibaba.nacos.api.selector.ExpressionSelector;
import com.alibaba.nacos.api.selector.SelectorType; import com.alibaba.nacos.api.selector.SelectorType;
import com.alibaba.nacos.client.monitor.MetricsMonitor; import com.alibaba.nacos.client.monitor.MetricsMonitor;
import com.alibaba.nacos.client.naming.beat.BeatInfo; import com.alibaba.nacos.client.naming.beat.BeatInfo;
import com.alibaba.nacos.client.naming.utils.CollectionUtils; import com.alibaba.nacos.client.naming.utils.*;
import com.alibaba.nacos.client.naming.utils.IoUtils;
import com.alibaba.nacos.client.naming.utils.NetUtils;
import com.alibaba.nacos.client.naming.utils.StringUtils;
import com.alibaba.nacos.client.naming.utils.UtilAndComs;
import com.alibaba.nacos.common.util.HttpMethod; import com.alibaba.nacos.common.util.HttpMethod;
import com.alibaba.nacos.common.util.UuidUtils; import com.alibaba.nacos.common.util.UuidUtils;
import java.io.IOException; import java.io.IOException;
import java.io.StringReader; import java.io.StringReader;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadFactory;
@ -344,10 +334,6 @@ public class NamingProxy {
return StringUtils.EMPTY; return StringUtils.EMPTY;
} }
NAMING_LOGGER.error("[CALL-SERVER] failed to req API:" + HttpClient.getPrefix() + curServer
+ api + ". code:"
+ result.code + " msg: " + result.content);
throw new NacosException(NacosException.SERVER_ERROR, "failed to req API:" + HttpClient.getPrefix() + curServer throw new NacosException(NacosException.SERVER_ERROR, "failed to req API:" + HttpClient.getPrefix() + curServer
+ api + ". code:" + api + ". code:"
+ result.code + " msg: " + result.content); + result.code + " msg: " + result.content);
@ -374,8 +360,10 @@ public class NamingProxy {
String server = servers.get(index); String server = servers.get(index);
try { try {
return callServer(api, params, server, method); return callServer(api, params, server, method);
} catch (NacosException e) {
NAMING_LOGGER.error("request {} failed.", server, e);
} catch (Exception e) { } catch (Exception e) {
NAMING_LOGGER.error("[NA] req api:" + api + " failed, server(" + server, e); NAMING_LOGGER.error("request {} failed.", server, e);
} }
index = (index + 1) % servers.size(); index = (index + 1) % servers.size();