...
|
...
|
@@ -58,13 +58,13 @@ public class GlobalDefaultExceptionHandler { |
|
|
}
|
|
|
|
|
|
//如果是业务异常,则返回http 200,并且构造json消息体中错误码&错误内容
|
|
|
if (e instanceof GatewayException || e instanceof ServiceException) {
|
|
|
if (e instanceof GatewayException || e instanceof ServiceException || e instanceof Exception) {
|
|
|
int code;
|
|
|
String desc;
|
|
|
if (e instanceof GatewayException) {
|
|
|
code = ((GatewayException) e).getErrorCode();
|
|
|
desc = ((GatewayException) e).getDesc();
|
|
|
} else { //服务异常,不能直接返回给客户端,必须映射一下
|
|
|
} else if(e instanceof ServiceException) { //服务异常,不能直接返回给客户端,必须映射一下
|
|
|
ServiceException serviceException = (ServiceException) e;
|
|
|
ServiceError serviceError = serviceException.getServiceError();
|
|
|
code = serviceError.getMappingGatewayError().getLeft();
|
...
|
...
|
@@ -72,6 +72,9 @@ public class GlobalDefaultExceptionHandler { |
|
|
if (serviceException.getParams() != null) {
|
|
|
desc = MessageFormat.format(desc, serviceException.getParams());
|
|
|
}
|
|
|
}else {
|
|
|
code = 500;
|
|
|
desc = "服务暂时异常,请稍等";
|
|
|
}
|
|
|
|
|
|
log.warn("service exception happened at:{}, code:{}, desc:{}, uri:{}, request: {}, params is: {}", serviceName, code, desc, request.getRequestURI(), serviceName, params);
|
...
|
...
|
|