bf1d357f5b28c2d572d72bba90442be0b22c1e27
[aaf/authz.git] / misc / env / src / main / java / org / onap / aaf / misc / env / APIException.java
1 /**\r
2  * ============LICENSE_START====================================================\r
3  * org.onap.aaf\r
4  * ===========================================================================\r
5  * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.\r
6  * ===========================================================================\r
7  * Licensed under the Apache License, Version 2.0 (the "License");\r
8  * you may not use this file except in compliance with the License.\r
9  * You may obtain a copy of the License at\r
10  * \r
11  *      http://www.apache.org/licenses/LICENSE-2.0\r
12  * \r
13  * Unless required by applicable law or agreed to in writing, software\r
14  * distributed under the License is distributed on an "AS IS" BASIS,\r
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  * See the License for the specific language governing permissions and\r
17  * limitations under the License.\r
18  * ============LICENSE_END====================================================\r
19  *\r
20  */\r
21 \r
22 package org.onap.aaf.misc.env;\r
23 \r
24 \r
25 /**\r
26  * An Exception with the ability to hold a payload.<p>\r
27  * \r
28  * This is important, because sometimes, the output of a Framework\r
29  * may be a descriptive object which doesn't inherit from Throwable\r
30  * and thus cannot be attached in "initCause".<p>\r
31  * \r
32  * Examples may be a SOAP Fault.\r
33  * \r
34  * @author Jonathan\r
35  *\r
36  */\r
37 public class APIException extends Exception {\r
38         \r
39         private Object payload = null;\r
40         \r
41         /**\r
42          * @param t\r
43          */\r
44         public APIException(Throwable t) {\r
45                 super(t);\r
46         }\r
47         \r
48         /**\r
49          * @param string\r
50          */\r
51         public APIException(String string) {\r
52                 super(string);\r
53         }\r
54 \r
55         /**\r
56          * @param errorMessage\r
57          * @param t\r
58          */\r
59         public APIException(String errorMessage, Throwable t) {\r
60                 super(errorMessage,t);\r
61         }\r
62 \r
63         /**\r
64          * Return payload, or null if none was set.  Type is up to the calling\r
65          * System.\r
66          * \r
67          * @return Object\r
68          */\r
69         public Object getPayload() {\r
70                 return payload;\r
71         }\r
72 \r
73         /**\r
74          * Set a specific payload into this Exception, which doesn't necessarily\r
75          * inherit from Throwable.\r
76          * \r
77          * @param payload\r
78          * @return APIException\r
79          */\r
80         public APIException setPayload(Object payload) {\r
81                 this.payload = payload;\r
82                 return this;\r
83         }\r
84 \r
85         /**\r
86          * Java expected serial ID\r
87          */\r
88         private static final long serialVersionUID = 3505343458251445169L;\r
89 }\r