85d486c91eeba6f6532dd0882cc66b77afbe3d94
[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
27   public ErrorCodeException(int code, String debugMessage) {
28     this(code, debugMessage, null);
29   }
30
31   /**
32    * error code exception.
33    * @param code error code
34    * @param debugMessage debug message
35    * @param arguments arguments
36    */
37   public ErrorCodeException(int code, String debugMessage, String[] arguments) {
38     super(debugMessage);
39     this.errorCode = code;
40     this.arguments = arguments;
41     this.categoryCode = 0;
42   }
43
44
45   public ErrorCodeException(Throwable source, int code) {
46     this(source, code, (String[]) null);
47   }
48
49   /**
50    * error code exception.
51    * @param source Throwable
52    * @param code error code
53    * @param arguments arguments
54    */
55   public ErrorCodeException(Throwable source, int code, String[] arguments) {
56     super(source);
57     this.errorCode = code;
58     this.arguments = arguments;
59     this.categoryCode = 0;
60   }
61
62
63   public ErrorCodeException(Throwable source, int code, String debugMessage) {
64     this(source, code, debugMessage, null);
65   }
66
67   /**
68    * error code exception.
69    * @param source Throwable
70    * @param code error code
71    * @param debugMessage debug message
72    * @param arguments arguments
73    */
74   public ErrorCodeException(Throwable source, int code, String debugMessage, String[] arguments) {
75     super(debugMessage, source);
76     this.errorCode = code;
77     this.arguments = arguments;
78     this.categoryCode = 0;
79   }
80
81
82   public ErrorCodeException(int category, int code, String debugMessage) {
83     this(category, code, debugMessage, null);
84   }
85
86
87   public ErrorCodeException(int category, int code, String debugMessage, String[] arguments) {
88     super(debugMessage);
89     this.categoryCode = category;
90     this.errorCode = code;
91     this.arguments = arguments;
92   }
93
94
95   public ErrorCodeException(Throwable source, int category, int code) {
96     this(source, category, code, (String[]) null);
97   }
98
99
100   public ErrorCodeException(Throwable source, int category, int code, String[] arguments) {
101     super(source);
102     this.categoryCode = category;
103     this.errorCode = code;
104     this.arguments = arguments;
105   }
106
107
108   public ErrorCodeException(Throwable source, int category, int code, String debugMessage) {
109     this(source, category, code, debugMessage, null);
110   }
111
112
113   public ErrorCodeException(Throwable source, int category, int code, String debugMessage,
114       String[] arguments) {
115     super(debugMessage, source);
116     this.categoryCode = category;
117     this.errorCode = code;
118     this.arguments = arguments;
119   }
120
121
122   public int getCategory() {
123     return categoryCode;
124   }
125
126   public int getErrorCode() {
127     return errorCode;
128   }
129
130
131   public String[] getArguments() {
132     return arguments;
133   }
134
135 }
136