ServiceException.java 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. @Override
  44. public String getMessage()
  45. {
  46. return message;
  47. }
  48. public Integer getCode()
  49. {
  50. return code;
  51. }
  52. public ServiceException setMessage(String message)
  53. {
  54. this.message = message;
  55. return this;
  56. }
  57. public ServiceException setDetailMessage(String detailMessage)
  58. {
  59. this.detailMessage = detailMessage;
  60. return this;
  61. }
  62. }