2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.onap.aai.exceptions;
22 import java.util.Collection;
23 import java.util.LinkedList;
25 import org.onap.aai.logging.ErrorLogHelper;
26 import org.onap.aai.logging.ErrorObject;
27 import org.onap.aai.logging.ErrorObjectNotFoundException;
29 public class AAIException extends Exception {
31 public static final String DEFAULT_EXCEPTION_CODE = "AAI_4000";
32 private static final long serialVersionUID = 1L;
34 private final String code;
35 private final ErrorObject errorObject;
36 private final Collection<String> templateVars;
39 * Instantiates a new AAI exception.
41 public AAIException() {
43 this.code = DEFAULT_EXCEPTION_CODE;
44 this.templateVars = new LinkedList<String> ();
47 this.errorObject = ErrorLogHelper.getErrorObject(getCode());
48 } catch (ErrorObjectNotFoundException e) {
49 throw new RuntimeException("Failed to instantiate AAIException with code=" + getCode()
50 + " - update error.properties before using this exception code");
55 * Instantiates a new AAI exception.
57 * @param code the code
59 public AAIException(String code) {
63 this.templateVars = new LinkedList<String> ();
66 this.errorObject = ErrorLogHelper.getErrorObject(getCode());
67 } catch (ErrorObjectNotFoundException e) {
68 throw new RuntimeException("Failed to instantiate AAIException with code=" + getCode()
69 + " - update error.properties before using this exception code");
74 * Instantiates a new AAI exception.
76 * @param code the code
77 * @param details the details
79 public AAIException(String code, String details) {
83 this.templateVars = new LinkedList<String> ();
86 this.errorObject = ErrorLogHelper.getErrorObject(getCode());
87 } catch (ErrorObjectNotFoundException e) {
88 throw new RuntimeException("Failed to instantiate AAIException with code=" + getCode()
89 + " - update error.properties before using this exception code");
94 * Instantiates a new AAI exception.
96 * @param code the code
97 * @param cause the cause
99 public AAIException(String code, Throwable cause) {
103 this.templateVars = new LinkedList<String> ();
106 this.errorObject = ErrorLogHelper.getErrorObject(getCode());
107 } catch (ErrorObjectNotFoundException e) {
108 throw new RuntimeException("Failed to instantiate AAIException with code=" + getCode()
109 + " - update error.properties before using this exception code");
114 * Instantiates a new AAI exception.
116 * @param code the code
117 * @param cause the cause
118 * @param details the details
120 public AAIException(String code, Throwable cause, String details) {
121 super(details, cause);
124 this.templateVars = new LinkedList<String> ();
127 this.errorObject = ErrorLogHelper.getErrorObject(getCode());
128 } catch (ErrorObjectNotFoundException e) {
129 throw new RuntimeException("Failed to instantiate AAIException with code=" + getCode()
130 + " - update error.properties before using this exception code");
134 public String getCode() {
138 public ErrorObject getErrorObject() {
142 public Collection<String> getTemplateVars() {