禅道bug#1599修复

This commit is contained in:
gaoqr
2026-06-04 11:29:17 +08:00
parent c61f994ed5
commit c5a471f5cc
8 changed files with 64 additions and 10 deletions
@@ -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;
}
@@ -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();
@@ -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;
}
/**