package com.casic.missiles.handler; import com.casic.missiles.dto.ReturnUtil; 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; /** * @Description: 全局异常处理 * @Author: wangpeng * @Date: 2022/11/24 8:50 */ @Slf4j @Order(1) @ControllerAdvice public class GlobalExceptionHandler { /** * 业务异常捕获处理 */ @ResponseBody @ExceptionHandler({BusinessException.class}) public Object handleError(BusinessException exception) { return ReturnUtil.failed(String.valueOf(exception.getCode()), exception.getMessage()); } }