错误异常响应内容处理

This commit is contained in:
tianliyong 2023-04-06 14:32:21 +08:00
parent da9c074236
commit f30e225a53

View File

@ -78,7 +78,7 @@ public abstract class AbstractExceptionApiResultHandler<T extends Throwable> imp
log(status, request, errorMsg, error);
// 6.返回body
return errBody(code, message, error);
return errBody(code, errorMsg, message, error);
}
protected T getRealCause(T ex) {
@ -155,8 +155,12 @@ public abstract class AbstractExceptionApiResultHandler<T extends Throwable> imp
}
}
protected ApiResult<?> errBody(String code, String message, Throwable error) {
return err(Integer.parseInt(code), message);
protected ApiResult<?> errBody(String code, String errorMsg, String message, Throwable error) {
if (error instanceof BizException) {
return err(Integer.parseInt(((BizException) error).getCode()), errorMsg);
} else {
return err(Integer.parseInt(code), message);
}
}
@Override