ServiceException.java 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. package com.ruoyi.common.exception;
  2. /**
  3. * 业务异常
  4. *
  5. * @author ruoyi
  6. */
  7. public final class ServiceException extends RuntimeException
  8. {
  9. private static final long serialVersionUID = 1L;
  10. /**
  11. * 错误码
  12. */
  13. private Integer code;
  14. /**
  15. * 错误提示
  16. */
  17. private String message;
  18. /**
  19. * 错误明细,内部调试错误
  20. *
  21. * 和 {@link CommonResult#getDetailMessage()} 一致的设计
  22. */
  23. private String detailMessage;
  24. /**
  25. * 空构造方法,避免反序列化问题
  26. */
  27. public ServiceException()
  28. {
  29. }
  30. public ServiceException(String message)
  31. {
  32. this.message = message;
  33. }
  34. public ServiceException(String message, Integer code)
  35. {
  36. this.message = message;
  37. this.code = code;
  38. }
  39. public String getDetailMessage()
  40. {
  41. return detailMessage;
  42. }
  43. public String getMessage()
  44. {
  45. return message;
  46. }
  47. public Integer getCode()
  48. {
  49. return code;
  50. }
  51. public ServiceException setMessage(String message)
  52. {
  53. this.message = message;
  54. return this;
  55. }
  56. public ServiceException setDetailMessage(String detailMessage)
  57. {
  58. this.detailMessage = detailMessage;
  59. return this;
  60. }
  61. }