2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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=========================================================
21 package org.openecomp.aai.exceptions;
23 import java.util.Collection;
24 import java.util.LinkedList;
26 import org.openecomp.aai.logging.ErrorLogHelper;
27 import org.openecomp.aai.logging.ErrorObject;
28 import org.openecomp.aai.logging.ErrorObjectNotFoundException;
30 public class AAIException extends Exception {
32 public static final String DEFAULT_EXCEPTION_CODE = "AAI_4000";
33 private static final long serialVersionUID = 1L;
35 private final String code;
36 private final ErrorObject errorObject;
37 private final Collection<String> templateVars;
40 * Instantiates a new AAI exception.
42 public AAIException() {
44 this.code = DEFAULT_EXCEPTION_CODE;
45 this.templateVars = new LinkedList<String> ();
48 this.errorObject = ErrorLogHelper.getErrorObject(getCode());
49 } catch (ErrorObjectNotFoundException e) {
50 throw new RuntimeException("Failed to instantiate AAIException with code=" + getCode()
51 + " - update error.properties before using this exception code");
56 * Instantiates a new AAI exception.
58 * @param code the code
60 public AAIException(String code) {
64 this.templateVars = new LinkedList<String> ();
67 this.errorObject = ErrorLogHelper.getErrorObject(getCode());
68 } catch (ErrorObjectNotFoundException e) {
69 throw new RuntimeException("Failed to instantiate AAIException with code=" + getCode()
70 + " - update error.properties before using this exception code");
75 * Instantiates a new AAI exception.
77 * @param code the code
78 * @param details the details
80 public AAIException(String code, String details) {
84 this.templateVars = new LinkedList<String> ();
87 this.errorObject = ErrorLogHelper.getErrorObject(getCode());
88 } catch (ErrorObjectNotFoundException e) {
89 throw new RuntimeException("Failed to instantiate AAIException with code=" + getCode()
90 + " - update error.properties before using this exception code");
95 * Instantiates a new AAI exception.
97 * @param code the code
98 * @param cause the cause
100 public AAIException(String code, Throwable cause) {
104 this.templateVars = new LinkedList<String> ();
107 this.errorObject = ErrorLogHelper.getErrorObject(getCode());
108 } catch (ErrorObjectNotFoundException e) {
109 throw new RuntimeException("Failed to instantiate AAIException with code=" + getCode()
110 + " - update error.properties before using this exception code");
115 * Instantiates a new AAI exception.
117 * @param code the code
118 * @param cause the cause
119 * @param details the details
121 public AAIException(String code, Throwable cause, String details) {
122 super(details, cause);
125 this.templateVars = new LinkedList<String> ();
128 this.errorObject = ErrorLogHelper.getErrorObject(getCode());
129 } catch (ErrorObjectNotFoundException e) {
130 throw new RuntimeException("Failed to instantiate AAIException with code=" + getCode()
131 + " - update error.properties before using this exception code");
135 public String getCode() {
139 public ErrorObject getErrorObject() {
143 public Collection<String> getTemplateVars() {