柯桥增值式服务
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.

66 lines
1.6KB

  1. package com.ningdatech.kqapi.common.exception;
  2. import cn.hutool.core.util.StrUtil;
  3. import com.ningdatech.kqapi.common.util.StrPool;
  4. /**
  5. * 非运行期异常基类,所有自定义非运行时异常继承该类
  6. *
  7. * @author WendyYang
  8. * @version 1.0
  9. * @see RuntimeException
  10. */
  11. public class BaseUncheckedException extends RuntimeException implements BaseException {
  12. private static final long serialVersionUID = -778887391066124051L;
  13. /**
  14. * 异常信息
  15. */
  16. private String message;
  17. /**
  18. * 具体异常码
  19. */
  20. private int code;
  21. public BaseUncheckedException(Throwable cause) {
  22. super(cause);
  23. }
  24. public BaseUncheckedException(final int code, Throwable cause) {
  25. super(cause);
  26. this.code = code;
  27. }
  28. public BaseUncheckedException(final int code, final String message) {
  29. super(message);
  30. this.code = code;
  31. this.message = message;
  32. }
  33. public BaseUncheckedException(final int code, final String message, Throwable cause) {
  34. super(cause);
  35. this.code = code;
  36. this.message = message;
  37. }
  38. public BaseUncheckedException(final int code, final String format, Object... args) {
  39. super(StrUtil.contains(format, StrPool.BRACE) ? StrUtil.format(format, args) : String.format(format, args));
  40. this.code = code;
  41. this.message = StrUtil.contains(format, StrPool.BRACE) ? StrUtil.format(format, args) : String.format(format, args);
  42. }
  43. @Override
  44. public String getMessage() {
  45. return message;
  46. }
  47. @Override
  48. public int getCode() {
  49. return code;
  50. }
  51. }