mirror of https://gitee.com/stylefeng/guns
【7.0.4】更新演示环境的操作提示
parent
c3c677ae25
commit
adb934a46b
7
pom.xml
7
pom.xml
|
@ -184,6 +184,13 @@
|
|||
<version>${roses.kernel.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--演示环境api-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>demo-api</artifactId>
|
||||
<version>${roses.kernel.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--数据库驱动,可根据自己需要自行删减-->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
|
|
|
@ -4,6 +4,8 @@ import cn.hutool.core.util.ObjectUtil;
|
|||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.stylefeng.roses.kernel.auth.api.exception.AuthException;
|
||||
import cn.stylefeng.roses.kernel.auth.api.exception.enums.AuthExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.demo.exception.DemoException;
|
||||
import cn.stylefeng.roses.kernel.demo.exception.enums.DemoExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.rule.constants.SymbolConstant;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.AbstractExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||
|
@ -16,6 +18,8 @@ import cn.stylefeng.roses.kernel.rule.util.ResponseRenderUtil;
|
|||
import cn.stylefeng.roses.kernel.validator.api.exception.ParamValidateException;
|
||||
import cn.stylefeng.roses.kernel.validator.api.exception.enums.ValidatorExceptionEnum;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.exceptions.PersistenceException;
|
||||
import org.mybatis.spring.MyBatisSystemException;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.ui.Model;
|
||||
|
@ -227,6 +231,28 @@ public class GlobalExceptionHandler {
|
|||
return renderJson(e.getErrorCode(), e.getUserTip(), e);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拦截mybatis数据库操作的异常
|
||||
* <p>
|
||||
* 用在demo模式,拦截DemoException
|
||||
*
|
||||
* @author stylefeng
|
||||
* @date 2020/5/5 15:19
|
||||
*/
|
||||
@ExceptionHandler(MyBatisSystemException.class)
|
||||
@ResponseBody
|
||||
public ErrorResponseData persistenceException(MyBatisSystemException e) {
|
||||
log.error(">>> mybatis操作出现异常,具体信息为:{}", e.getMessage());
|
||||
Throwable cause = e.getCause();
|
||||
if (cause instanceof PersistenceException) {
|
||||
Throwable secondCause = cause.getCause();
|
||||
if (secondCause instanceof DemoException) {
|
||||
return renderJson(DemoExceptionEnum.DEMO_OPERATE);
|
||||
}
|
||||
}
|
||||
return renderJson(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拦截未知的运行时异常
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue