5f10b425c82c47de5ce75d1654ca2ea3083be71b
[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   public static final int DEFAULT_CODE = -1;
11
12   /**
13    * 具体异常码
14    */
15   protected int code = -1;
16
17   public BaseException(int code, String msgFormat, Object... args) {
18       super(String.format(msgFormat, args));
19       this.code = code;
20   }
21
22   public BaseException() {
23       super();
24   }
25
26   public BaseException(String message, Throwable cause) {
27       super(message, cause);
28   }
29
30   public BaseException(Throwable cause) {
31       super(cause);
32   }
33
34   public BaseException(String message) {
35       super(message);
36   }
37
38   public int getCode() {
39       return code;
40   }
41
42   /**
43    * 实例化异常
44    * 
45    * @param msgFormat
46    * @param args
47    * @return
48    */
49   @Deprecated
50   public static BaseException newInstance(String msgFormat, Object... args) {
51       return new BaseException(DEFAULT_CODE, msgFormat, args);
52   }
53   
54   public static BaseException newInstance(int code, String msgFormat, Object... args) {
55     return new BaseException(code, msgFormat, args);
56   }
57
58 }