Java Code Examples for com.alibaba.nacos.api.exception.NacosException#SERVER_ERROR

The following examples show how to use com.alibaba.nacos.api.exception.NacosException#SERVER_ERROR . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EventPublishingConfigService.java    From nacos-spring-project with Apache License 2.0 5 votes vote down vote up
@Override
public String getConfig(String dataId, String group, long timeoutMs)
		throws NacosException {
	try {
		return configService.getConfig(dataId, group, timeoutMs);
	}
	catch (NacosException e) {
		if (NacosException.SERVER_ERROR == e.getErrCode()) { // timeout error
			publishEvent(new NacosConfigTimeoutEvent(configService, dataId, group,
					timeoutMs, e.getErrMsg()));
		}
		throw e; // re-throw NacosException
	}
}
 
Example 2
Source File: MockConfigService.java    From nacos-spring-project with Apache License 2.0 5 votes vote down vote up
@Override
public String getConfig(String dataId, String group, long timeoutMs)
		throws NacosException {
	String key = createKey(dataId, group);
	if (timeoutMs < 0) {
		throw new NacosException(NacosException.SERVER_ERROR, TIMEOUT_ERROR_MESSAGE);
	}
	return contentCache.get(key);
}
 
Example 3
Source File: NacosFailureAnalyzer.java    From nacos-spring-boot-project with Apache License 2.0 4 votes vote down vote up
@Override
protected FailureAnalysis analyze(Throwable rootFailure, NacosException cause) {
	StringBuilder description = new StringBuilder();
	switch (cause.getErrCode()) {
	case NacosException.CLIENT_INVALID_PARAM:
		description.append("client error: invalid param");
		break;
	case NacosException.CLIENT_OVER_THRESHOLD:
		description.append("client error: over client threshold");
		break;
	case NacosException.BAD_GATEWAY:
		description.append("server error: bad gateway");
		break;
	case NacosException.CONFLICT:
		description.append("server error: conflict");
		break;
	case NacosException.INVALID_PARAM:
		description.append("server error: invalid param");
		break;
	case NacosException.NO_RIGHT:
		description.append("server error: no right");
		break;
	case NacosException.OVER_THRESHOLD:
		description.append("server error: over threshold");
		break;
	case NacosException.SERVER_ERROR:
		description.append("server error: such as timeout");
		break;
	default:
		description.append("unknown reason");
	}
	description.append(". ").append(cause.getErrMsg());
	String action;
	if (description.toString().contains("client")) {
		action = "please check your client configuration";
	}
	else {
		action = "please check server status";
	}
	return new FailureAnalysis(description.toString(), action, cause);
}