/**
 * @author wen.jie
 * @Classname GlobalExceptionHandler
 * @Description 统一异常处理
 * @Date 2020/6/27
 */
@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(value = {ArithmeticException.class})
    public Object handlerException(Exception e){
        log.info(Arrays.toString(e.getStackTrace()));
        return new CommonResult().failed("数学算数异常");
    }

    @ExceptionHandler(value = {NullPointerException.class})
    public Object handlerException2(Exception e){
        log.info(Arrays.toString(e.getStackTrace()));
        return new CommonResult().failed("空指针异常");
    }

    @ExceptionHandler(value = {IndexOutOfBoundsException.class})
    public Object handlerException3(Exception e){
        log.info(Arrays.toString(e.getStackTrace()));
        return new CommonResult().failed("下标越界异常");
    }
}

  

相关文章:

  • 2022-12-23
  • 2022-01-03
  • 2021-10-29
  • 2021-07-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-26
猜你喜欢
  • 2021-09-25
  • 2021-08-12
  • 2021-09-05
  • 2021-10-10
  • 2021-10-09
  • 2021-10-29
相关资源
相似解决方案