9921a8cba8afd305e56068b69b184cc91aeb1bd6
[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.onap.vnfsdk.marketplace.db.exception;
17
18
19 public class ErrorCodeException extends Exception {
20
21   private static final long serialVersionUID = 3220072444842529499L;
22   private final int categoryCode;
23   private final int errorCode;
24   private final String[] arguments;
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     this.categoryCode = 0;
54   }
55
56
57   public ErrorCodeException(Throwable source, int code) {
58     this(source, code, (String[]) null);
59   }
60
61   /**
62    * error code exception.
63    * @param source Throwable
64    * @param code error code
65    * @param arguments arguments
66    */
67   public ErrorCodeException(Throwable source, int code, String[] arguments) {
68     super(source);
69     this.errorCode = code;
70     this.arguments = arguments;
71     this.categoryCode = 0;
72   }
73
74
75   public ErrorCodeException(Throwable source, int code, String debugMessage) {
76     this(source, code, debugMessage, null);
77   }
78
79   /**
80    * error code exception.
81    * @param source Throwable
82    * @param code error code
83    * @param debugMessage debug message
84    * @param arguments arguments
85    */
86   public ErrorCodeException(Throwable source, int code, String debugMessage, String[] arguments) {
87     super(debugMessage, source);
88     this.errorCode = code;
89     this.arguments = arguments;
90     this.categoryCode = 0;
91   }
92
93
94   public ErrorCodeException(int category, int code, String debugMessage) {
95     this(category, code, debugMessage, null);
96   }
97
98
99   public ErrorCodeException(int category, int code, String debugMessage, String[] arguments) {
100     super(debugMessage);
101     this.categoryCode = category;
102     this.errorCode = code;
103     this.arguments = arguments;
104   }
105
106
107   public ErrorCodeException(Throwable source, int category, int code) {
108     this(source, category, code, (String[]) null);
109   }
110
111
112   public ErrorCodeException(Throwable source, int category, int code, String[] arguments) {
113     super(source);
114     this.categoryCode = category;
115     this.errorCode = code;
116     this.arguments = arguments;
117   }
118
119
120   public ErrorCodeException(Throwable source, int category, int code, String debugMessage) {
121     this(source, category, code, debugMessage, null);
122   }
123
124
125   public ErrorCodeException(Throwable source, int category, int code, String debugMessage,
126       String[] arguments) {
127     super(debugMessage, source);
128     this.categoryCode = category;
129     this.errorCode = code;
130     this.arguments = arguments;
131   }
132
133
134   public int getCategory() {
135     return categoryCode;
136   }
137
138   public int getErrorCode() {
139     return errorCode;
140   }
141
142
143   public String[] getArguments() {
144     return arguments;
145   }
146
147 }