93472b05dd5625c106f0ad099fade261fdb18e99
[vnfsdk/refrepo.git] /
1 /**
2  * Copyright 2017 Huawei Technologies Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.openo.vnfsdk.marketplace.db.exception;
17
18
19 public class ErrorCodeException extends Exception {
20
21   private static final long serialVersionUID = 3220072444842529499L;
22   private int categoryCode = 0;
23   private int errorCode = 1;
24   private String[] arguments = null;
25
26   private static String defaultText = null;
27
28
29   public static void setDefaultText(String text) {
30     defaultText = text;
31   }
32
33
34   public static String getDefaultText() {
35     return defaultText;
36   }
37
38
39   public ErrorCodeException(int code, String debugMessage) {
40     this(code, debugMessage, null);
41   }
42
43   /**
44    * error code exception.
45    * @param code error code
46    * @param debugMessage debug message
47    * @param arguments arguments
48    */
49   public ErrorCodeException(int code, String debugMessage, String[] arguments) {
50     super(debugMessage);
51     this.errorCode = code;
52     this.arguments = arguments;
53   }
54
55
56   public ErrorCodeException(Throwable source, int code) {
57     this(source, code, (String[]) null);
58   }
59
60   /**
61    * error code exception.
62    * @param source Throwable
63    * @param code error code
64    * @param arguments arguments
65    */
66   public ErrorCodeException(Throwable source, int code, String[] arguments) {
67     super(source);
68     this.errorCode = code;
69     this.arguments = arguments;
70   }
71
72
73   public ErrorCodeException(Throwable source, int code, String debugMessage) {
74     this(source, code, debugMessage, null);
75   }
76
77   /**
78    * error code exception.
79    * @param source Throwable
80    * @param code error code
81    * @param debugMessage debug message
82    * @param arguments arguments
83    */
84   public ErrorCodeException(Throwable source, int code, String debugMessage, String[] arguments) {
85     super(debugMessage, source);
86     this.errorCode = code;
87     this.arguments = arguments;
88   }
89
90
91   public ErrorCodeException(int category, int code, String debugMessage) {
92     this(category, code, debugMessage, null);
93   }
94
95
96   public ErrorCodeException(int category, int code, String debugMessage, String[] arguments) {
97     super(debugMessage);
98     this.categoryCode = category;
99     this.errorCode = code;
100     this.arguments = arguments;
101   }
102
103
104   public ErrorCodeException(Throwable source, int category, int code) {
105     this(source, category, code, (String[]) null);
106   }
107
108
109   public ErrorCodeException(Throwable source, int category, int code, String[] arguments) {
110     super(source);
111     this.categoryCode = category;
112     this.errorCode = code;
113     this.arguments = arguments;
114   }
115
116
117   public ErrorCodeException(Throwable source, int category, int code, String debugMessage) {
118     this(source, category, code, debugMessage, null);
119   }
120
121
122   public ErrorCodeException(Throwable source, int category, int code, String debugMessage,
123       String[] arguments) {
124     super(debugMessage, source);
125     this.categoryCode = category;
126     this.errorCode = code;
127     this.arguments = arguments;
128   }
129
130
131   public int getCategory() {
132     return categoryCode;
133   }
134
135   public int getErrorCode() {
136     return errorCode;
137   }
138
139
140   public String[] getArguments() {
141     return arguments;
142   }
143
144 }