mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
禅道bug#1599修复
This commit is contained in:
+14
@@ -0,0 +1,14 @@
|
||||
package com.cf.imes.framework.common.exception;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 异常错误数据:用于CommonResult.data
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2026/6/4 10:40
|
||||
*/
|
||||
@Data
|
||||
public class ErrorData {
|
||||
private String errorData;
|
||||
}
|
||||
+12
@@ -31,12 +31,24 @@ public final class ServiceException extends RuntimeException {
|
||||
*/
|
||||
private transient Object[] args;
|
||||
|
||||
/**
|
||||
* 异常需要的回调数据
|
||||
*/
|
||||
private ErrorData errorData;
|
||||
|
||||
/**
|
||||
* 空构造方法,避免反序列化问题
|
||||
*/
|
||||
public ServiceException() {
|
||||
}
|
||||
|
||||
public ServiceException(ErrorCode errorCode, ErrorData errorData, Object... args) {
|
||||
this.code = errorCode.getCode();
|
||||
this.message = errorCode.getMsg();
|
||||
this.errorData = errorData;
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
public ServiceException(ErrorCode errorCode, Object... args) {
|
||||
this.code = errorCode.getCode();
|
||||
this.message = errorCode.getMsg();
|
||||
|
||||
+9
-2
@@ -3,6 +3,8 @@ package com.cf.imes.framework.web.core.handler;
|
||||
import cn.hutool.core.exceptions.ExceptionUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.cf.imes.framework.common.exception.ErrorData;
|
||||
import com.cf.imes.framework.common.exception.ServiceException;
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.framework.common.util.monitor.TracerUtils;
|
||||
@@ -238,12 +240,17 @@ public class GlobalExceptionHandler {
|
||||
@ExceptionHandler(value = ServiceException.class)
|
||||
public CommonResult serviceExceptionHandler(ServiceException ex) {
|
||||
// 系统异常输出堆栈
|
||||
if(INTERNAL_SERVER_ERROR.getCode().equals(ex.getCode())) {
|
||||
if (INTERNAL_SERVER_ERROR.getCode().equals(ex.getCode())) {
|
||||
log.error("[serviceExceptionHandler]", ex);
|
||||
} else {
|
||||
log.error(String.format("==========[serviceExceptionHandler]==========,%s:%s", ex.getCode(), ex.getMessage()));
|
||||
}
|
||||
return CommonResult.error(ex.getCode(), ex.getMessage(), ex.getArgs());
|
||||
CommonResult<Object> error = CommonResult.error(ex.getCode(), ex.getMessage(), ex.getArgs());
|
||||
ErrorData errorData = ex.getErrorData();
|
||||
if (ObjectUtil.isNotNull(errorData)) {
|
||||
error.setData(errorData.getErrorData());
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user