2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 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=========================================================
20 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 package org.onap.aai.exceptions;
24 import java.util.Collection;
25 import java.util.LinkedList;
27 import org.onap.aai.logging.ErrorLogHelper;
28 import org.onap.aai.logging.ErrorObject;
29 import org.onap.aai.logging.ErrorObjectNotFoundException;
31 public class AAIException extends Exception {
33 public static final String DEFAULT_EXCEPTION_CODE = "AAI_4000";
34 private static final long serialVersionUID = 1L;
36 private final String code;
37 private final ErrorObject errorObject;
38 private final Collection<String> templateVars;
41 * Instantiates a new AAI exception.
43 public AAIException() {
45 this.code = DEFAULT_EXCEPTION_CODE;
46 this.templateVars = new LinkedList<String> ();
49 this.errorObject = ErrorLogHelper.getErrorObject(getCode());
50 } catch (ErrorObjectNotFoundException e) {
51 throw new RuntimeException("Failed to instantiate AAIException with code=" + getCode()
52 + " - update error.properties before using this exception code");
57 * Instantiates a new AAI exception.
59 * @param code the code
61 public AAIException(String code) {
65 this.templateVars = new LinkedList<String> ();
68 this.errorObject = ErrorLogHelper.getErrorObject(getCode());
69 } catch (ErrorObjectNotFoundException e) {
70 throw new RuntimeException("Failed to instantiate AAIException with code=" + getCode()
71 + " - update error.properties before using this exception code");
76 * Instantiates a new AAI exception.
78 * @param code the code
79 * @param details the details
81 public AAIException(String code, String details) {
85 this.templateVars = new LinkedList<String> ();
88 this.errorObject = ErrorLogHelper.getErrorObject(getCode());
89 } catch (ErrorObjectNotFoundException e) {
90 throw new RuntimeException("Failed to instantiate AAIException with code=" + getCode()
91 + " - update error.properties before using this exception code");
96 * Instantiates a new AAI exception.
98 * @param code the code
99 * @param cause the cause
101 public AAIException(String code, Throwable cause) {
105 this.templateVars = new LinkedList<String> ();
108 this.errorObject = ErrorLogHelper.getErrorObject(getCode());
109 } catch (ErrorObjectNotFoundException e) {
110 throw new RuntimeException("Failed to instantiate AAIException with code=" + getCode()
111 + " - update error.properties before using this exception code");
116 * Instantiates a new AAI exception.
118 * @param code the code
119 * @param cause the cause
120 * @param details the details
122 public AAIException(String code, Throwable cause, String details) {
123 super(details, cause);
126 this.templateVars = new LinkedList<String> ();
129 this.errorObject = ErrorLogHelper.getErrorObject(getCode());
130 } catch (ErrorObjectNotFoundException e) {
131 throw new RuntimeException("Failed to instantiate AAIException with code=" + getCode()
132 + " - update error.properties before using this exception code");
136 public String getCode() {
140 public ErrorObject getErrorObject() {
144 public Collection<String> getTemplateVars() {