SysException.java 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package com.jtgh.yjpt.common;
  2. /**
  3. * 业务系统的异常类,主要用于封装业务逻辑错,给客户端提示 同时还可以封装系统错
  4. */
  5. public class SysException extends RuntimeException {
  6. private static final long serialVersionUID = -9013803276532569636L;
  7. /**
  8. * 警告,此时系统不记日志
  9. */
  10. public static final int INFTYPE_WARNING = 1;
  11. /**
  12. * 错误,此时系统记日志
  13. */
  14. public static final int INFTYPE_ERROR = 2;
  15. /**
  16. * 信息类型: 1警告 2错误
  17. */
  18. private int infType = INFTYPE_WARNING;
  19. private boolean showDetial = false;
  20. public SysException() {
  21. super();
  22. }
  23. public SysException(String message) {
  24. super(message);
  25. this.setInfType(INFTYPE_WARNING);
  26. }
  27. public SysException(Throwable cause) {
  28. super(cause);
  29. this.setInfType(INFTYPE_ERROR);
  30. }
  31. public SysException(String message, Throwable cause) {
  32. super(message, cause);
  33. this.setInfType(INFTYPE_ERROR);
  34. }
  35. public SysException(String message, int infType) {
  36. this(message);
  37. this.setInfType(infType);
  38. }
  39. public SysException(Throwable cause, int infType) {
  40. super(cause);
  41. this.setInfType(infType);
  42. }
  43. public SysException(String message, Throwable cause, int infType) {
  44. super(message, cause);
  45. this.setInfType(infType);
  46. }
  47. public int getInfType() {
  48. return infType;
  49. }
  50. public void setInfType(int infType) {
  51. this.infType = infType;
  52. }
  53. public boolean isShowDetial() {
  54. return showDetial;
  55. }
  56. public SysException setShowDetial(boolean showdetial) {
  57. this.showDetial = showdetial;
  58. return this;
  59. }
  60. }