3a850a5d18169c8565bc9f71ca801367989f8e47
[vfc/nfvo/catalog.git] /
1 /**
2  * Copyright 2016 [ZTE] and others.
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
17 package org.openo.commontosca.catalog.db.exception;
18
19
20 public class ErrorCodeException extends Exception {
21
22   private static final long serialVersionUID = 3220072444842529499L;
23   private int categoryCode = 0;
24   private int errorCode = 1;
25   private String[] arguments = null;
26
27   private static String defaultText = null;
28
29
30   public static void setDefaultText(String text) {
31     defaultText = text;
32   }
33
34
35   public static String getDefaultText() {
36     return defaultText;
37   }
38
39
40   public ErrorCodeException(int code, String debugMessage) {
41     this(code, debugMessage, null);
42   }
43
44   /**
45    * error code exception.
46    * @param code error code
47    * @param debugMessage debug message
48    * @param arguments arguments
49    */
50   public ErrorCodeException(int code, String debugMessage, String[] arguments) {
51     super(debugMessage);
52     this.errorCode = code;
53     this.arguments = arguments;
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   }
72
73
74   public ErrorCodeException(Throwable source, int code, String debugMessage) {
75     this(source, code, debugMessage, null);
76   }
77
78   /**
79    * error code exception.
80    * @param source Throwable
81    * @param code error code
82    * @param debugMessage debug message
83    * @param arguments arguments
84    */
85   public ErrorCodeException(Throwable source, int code, String debugMessage, String[] arguments) {
86     super(debugMessage, source);
87     this.errorCode = code;
88     this.arguments = arguments;
89   }
90
91
92   public ErrorCodeException(int category, int code, String debugMessage) {
93     this(category, code, debugMessage, null);
94   }
95
96
97   public ErrorCodeException(int category, int code, String debugMessage, String[] arguments) {
98     super(debugMessage);
99     this.categoryCode = category;
100     this.errorCode = code;
101     this.arguments = arguments;
102   }
103
104
105   public ErrorCodeException(Throwable source, int category, int code) {
106     this(source, category, code, (String[]) null);
107   }
108
109
110   public ErrorCodeException(Throwable source, int category, int code, String[] arguments) {
111     super(source);
112     this.categoryCode = category;
113     this.errorCode = code;
114     this.arguments = arguments;
115   }
116
117
118   public ErrorCodeException(Throwable source, int category, int code, String debugMessage) {
119     this(source, category, code, debugMessage, null);
120   }
121
122
123   public ErrorCodeException(Throwable source, int category, int code, String debugMessage,
124       String[] arguments) {
125     super(debugMessage, source);
126     this.categoryCode = category;
127     this.errorCode = code;
128     this.arguments = arguments;
129   }
130
131
132   public int getCategory() {
133     return categoryCode;
134   }
135
136   public int getErrorCode() {
137     return errorCode;
138   }
139
140
141   public String[] getArguments() {
142     return arguments;
143   }
144
145 }