ServiceException.java 1.3 KB

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