package com.dy.pmsGlobal.aop; import com.dy.common.webUtil.BaseResponse; import com.dy.common.webUtil.BaseResponseUtils; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestControllerAdvice; @ResponseBody @RestControllerAdvice @Slf4j public class ExceptionHandlerAdvice { /** * 处理系统异常,兜底处理所有异常 */ @ExceptionHandler(value = Exception.class) public BaseResponse defaultExceptionHandler(Throwable ex) { log.error("[defaultExceptionHandler]", ex); // 返回 ERROR return BaseResponseUtils.buildException(ex.getMessage()); } }