BusinessException.java 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package com.xynet.pay.Exception;
  2. /**
  3. * 业务异常
  4. *
  5. * @author yangsj
  6. */
  7. public class BusinessException extends RuntimeException
  8. {
  9. private static final long serialVersionUID = 5808616192752024016L;
  10. private String code;
  11. private Object[] args;
  12. public BusinessException()
  13. {
  14. }
  15. public BusinessException(String code, String msg)
  16. {
  17. super(msg);
  18. this.code = code;
  19. }
  20. public BusinessException(String code, String msg, Object[] _args)
  21. {
  22. super(msg);
  23. this.code = code;
  24. this.args = _args;
  25. }
  26. public BusinessException(Throwable exception)
  27. {
  28. super(exception);
  29. getExceptionCode(exception);
  30. }
  31. private void getExceptionCode(Throwable exception)
  32. {
  33. if ((exception instanceof BusinessException))
  34. {
  35. this.code = ((BusinessException)exception).getCode();
  36. }
  37. else
  38. {
  39. this.code = "999999";
  40. }
  41. }
  42. public String getCode() {
  43. return this.code;
  44. }
  45. public void setCode(String code) {
  46. this.code = code;
  47. }
  48. public Object[] getArgs() {
  49. return this.args;
  50. }
  51. public void setArgs(Object[] args) {
  52. this.args = args;
  53. }
  54. }