You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
658 B

  1. package com.example.demo.Util;
  2. /**
  3. * @program: GOLD
  4. * @ClassName BusinessException
  5. * @description:
  6. * @author: huangqizhen
  7. * @create: 202506-23 14:58
  8. * @Version 1.0
  9. **/
  10. import lombok.Getter;
  11. /**
  12. * 业务异常可抛出到前端
  13. */
  14. @Getter
  15. public class BusinessException extends RuntimeException {
  16. private int code; // 业务状态码
  17. // 使用默认状态码0的构造方法
  18. public BusinessException(String message) {
  19. this(400, message); // 默认状态码400
  20. }
  21. // 指定状态码的构造方法
  22. public BusinessException(int code, String message) {
  23. super(message);
  24. this.code = code;
  25. }
  26. }