package cn.com.app.base.exception;
import cn.com.app.base.dto.SystemExceptionMsgDto;
import cn.com.app.base.service.SystemExcepWxWarnService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
/**
* 全局校验异常处理
* ClassName: GlobalExceptionHandler
* Function:
* Date: 2020年6月4日 下午1:59:14
*/
@RestControllerAdvice
public class GlobalExceptionHandler {
@Autowired
private SystemExcepWxWarnService systemExcepWxWarnService;
@ExceptionHandler(Exception.class)
public void handleException(Exception e) {
BUSILOGGER.info("系统异常--------->",e);
// 发送企业微信预警
SystemExceptionMsgDto systemExceptionMsgDto = SystemExceptionMsgDto.builder()
.exceptionDesc(e.getMessage())
.exception(e)
.build();
systemExcepWxWarnService.sendWxMessage(systemExceptionMsgDto);
}
}
全局异常处理
于 2023-08-22 20:10:34 首次发布