package com.casic.missiles.handler; import com.casic.missiles.core.base.response.ResponseData; import com.casic.missiles.exception.BusinessException; import lombok.extern.slf4j.Slf4j; import org.springframework.core.annotation.Order; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody; @Slf4j @Order(3) @ControllerAdvice public class GlobalExceptionServerHandler { /** * 业务异常捕获处理 */ @ResponseBody @ExceptionHandler({BusinessException.class}) public Object handleError(BusinessException exception) { return ResponseData.error(exception.getCode(), exception.getMessage()); } // /** // * 编号重复异常捕获处理 // */ // @ResponseBody // @ExceptionHandler({DuplicateKeyException.class}) // public Object handleDuplicateKeyException() { // return ReturnUtil.failed(BusinessExceptionEnum.DUPLICATE_NUMBER.getCode(), BusinessExceptionEnum.DUPLICATE_NUMBER.getMessage()); // } // // /** // * 参数校验失败异常 // */ // @ResponseBody // @ExceptionHandler({MethodArgumentNotValidException.class}) // public Object handleMethodArgumentNotValidException(MethodArgumentNotValidException exception) { // return ReturnUtil.failed(BusinessExceptionEnum.PARAM_INVALID.getCode(), exception.getFieldError().getDefaultMessage()); // } }