This commit is contained in:
parent
d0bf21a756
commit
1decd04008
@ -42,7 +42,7 @@ public class ConfigFactory {
|
||||
ConfigService vendorImpl = (ConfigService) constructor.newInstance(properties);
|
||||
return vendorImpl;
|
||||
} catch (Throwable e) {
|
||||
throw new NacosException(-400, e.getMessage());
|
||||
throw new NacosException(NacosException.CLIENT_INVALID_PARAM, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,8 @@ public class NacosException extends Exception {
|
||||
|
||||
private String errMsg;
|
||||
|
||||
private Throwable throwable;
|
||||
|
||||
public NacosException() {
|
||||
}
|
||||
|
||||
@ -40,6 +42,19 @@ public class NacosException extends Exception {
|
||||
this.errMsg = errMsg;
|
||||
}
|
||||
|
||||
public NacosException(int errCode, Throwable throwable) {
|
||||
super(throwable);
|
||||
this.errCode = errCode;
|
||||
this.throwable = throwable;
|
||||
}
|
||||
|
||||
public NacosException(int errCode, String errMsg, Throwable throwable) {
|
||||
super(errMsg, throwable);
|
||||
this.errCode = errCode;
|
||||
this.errMsg = errMsg;
|
||||
this.throwable = throwable;
|
||||
}
|
||||
|
||||
public int getErrCode() {
|
||||
return errCode;
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public class NamingFactory {
|
||||
NamingService vendorImpl = (NamingService)constructor.newInstance(serverList);
|
||||
return vendorImpl;
|
||||
} catch (Throwable e) {
|
||||
throw new NacosException(-400, e.getMessage());
|
||||
throw new NacosException(NacosException.CLIENT_INVALID_PARAM, e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ public class NamingFactory {
|
||||
NamingService vendorImpl = (NamingService)constructor.newInstance(properties);
|
||||
return vendorImpl;
|
||||
} catch (Throwable e) {
|
||||
throw new NacosException(-400, e.getMessage());
|
||||
throw new NacosException(NacosException.CLIENT_INVALID_PARAM, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public class NamingMaintainFactory {
|
||||
NamingMaintainService vendorImpl = (NamingMaintainService)constructor.newInstance(serverList);
|
||||
return vendorImpl;
|
||||
} catch (Throwable e) {
|
||||
throw new NacosException(-400, e.getMessage());
|
||||
throw new NacosException(NacosException.CLIENT_INVALID_PARAM, e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ public class NamingMaintainFactory {
|
||||
NamingMaintainService vendorImpl = (NamingMaintainService)constructor.newInstance(properties);
|
||||
return vendorImpl;
|
||||
} catch (Throwable e) {
|
||||
throw new NacosException(-400, e.getMessage());
|
||||
throw new NacosException(NacosException.CLIENT_INVALID_PARAM, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@ public class ClientWorker {
|
||||
"[%s] [sub-server] get server config exception, dataId=%s, group=%s, tenant=%s", agent.getName(),
|
||||
dataId, group, tenant);
|
||||
LOGGER.error(message, e);
|
||||
throw new NacosException(NacosException.SERVER_ERROR, e.getMessage());
|
||||
throw new NacosException(NacosException.SERVER_ERROR, e);
|
||||
}
|
||||
|
||||
switch (result.code) {
|
||||
|
@ -51,7 +51,7 @@ public class RaftConsistencyServiceImpl implements PersistentConsistencyService
|
||||
raftCore.signalPublish(key, value);
|
||||
} catch (Exception e) {
|
||||
Loggers.RAFT.error("Raft put failed.", e);
|
||||
throw new NacosException(NacosException.SERVER_ERROR, "Raft put failed, key:" + key + ", value:" + value);
|
||||
throw new NacosException(NacosException.SERVER_ERROR, "Raft put failed, key:" + key + ", value:" + value, e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ public class RaftConsistencyServiceImpl implements PersistentConsistencyService
|
||||
raftCore.unlistenAll(key);
|
||||
} catch (Exception e) {
|
||||
Loggers.RAFT.error("Raft remove failed.", e);
|
||||
throw new NacosException(NacosException.SERVER_ERROR, "Raft remove failed, key:" + key);
|
||||
throw new NacosException(NacosException.SERVER_ERROR, "Raft remove failed, key:" + key, e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,7 +98,7 @@ public class RaftConsistencyServiceImpl implements PersistentConsistencyService
|
||||
raftCore.onPublish(datum, source);
|
||||
} catch (Exception e) {
|
||||
Loggers.RAFT.error("Raft onPut failed.", e);
|
||||
throw new NacosException(NacosException.SERVER_ERROR, "Raft onPut failed, datum:" + datum + ", source: " + source);
|
||||
throw new NacosException(NacosException.SERVER_ERROR, "Raft onPut failed, datum:" + datum + ", source: " + source, e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ public class RaftConsistencyServiceImpl implements PersistentConsistencyService
|
||||
raftCore.onDelete(datum.key, source);
|
||||
} catch (Exception e) {
|
||||
Loggers.RAFT.error("Raft onRemove failed.", e);
|
||||
throw new NacosException(NacosException.SERVER_ERROR, "Raft onRemove failed, datum:" + datum + ", source: " + source);
|
||||
throw new NacosException(NacosException.SERVER_ERROR, "Raft onRemove failed, datum:" + datum + ", source: " + source, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user