ee21f7a126722a5eb4eebfa0d68deefc18c3bf18
[institute/sw-backend.git] /
1 package com.supwisdom.institute.backend.common.framework.exception;
2
3 public class BaseException extends RuntimeException {
4
5   /**
6    * 
7    */
8   private static final long serialVersionUID = 2278568118369300446L;
9
10   /**
11    * 异常信息
12    */
13   protected String msg;
14
15   /**
16    * 具体异常码
17    */
18   protected int code = -1;
19
20   public BaseException(int code, String msgFormat, Object... args) {
21       super(String.format(msgFormat, args));
22       this.code = code;
23       this.msg = String.format(msgFormat, args);
24   }
25
26   public BaseException() {
27       super();
28   }
29
30   public BaseException(String message, Throwable cause) {
31       super(message, cause);
32   }
33
34   public BaseException(Throwable cause) {
35       super(cause);
36   }
37
38   public BaseException(String message) {
39       super(message);
40   }
41
42   public String getMsg() {
43       return msg;
44   }
45
46   public int getCode() {
47       return code;
48   }
49
50   /**
51    * 实例化异常
52    * 
53    * @param msgFormat
54    * @param args
55    * @return
56    */
57   @Deprecated
58   public BaseException newInstance(String msgFormat, Object... args) {
59       return new BaseException(this.code, msgFormat, args);
60   }
61   
62   public BaseException newInstance(int code, String msgFormat, Object... args) {
63     return new BaseException(code, msgFormat, args);
64   }
65
66 }