2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Modifications Copyright © 2018 IBM.
8 * Modifications Copyright (C) 2023 Deutsche Telekom SA.
9 * ================================================================================
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 * ============LICENSE_END=========================================================
24 package org.onap.aai.exceptions;
26 import java.util.Collection;
27 import java.util.LinkedList;
29 import org.onap.aai.logging.ErrorLogHelper;
30 import org.onap.aai.logging.ErrorObject;
31 import org.onap.aai.logging.ErrorObjectNotFoundException;
33 public class AAIException extends Exception {
35 public static final String DEFAULT_EXCEPTION_CODE = "AAI_4000";
36 private static final long serialVersionUID = 1L;
38 private final String code;
39 private final ErrorObject errorObject;
40 private final Collection<String> templateVars;
43 * Instantiates a new AAI exception.
45 public AAIException() {
47 this.code = DEFAULT_EXCEPTION_CODE;
48 this.templateVars = new LinkedList<>();
50 this.errorObject = ErrorLogHelper.getErrorObject(getCode());
54 * Instantiates a new AAI exception.
56 * @param code the code
58 public AAIException(String code) {
62 this.templateVars = new LinkedList<>();
63 this.errorObject = ErrorLogHelper.getErrorObject(getCode());
67 * Instantiates a new AAI exception.
69 * @param code the code
70 * @param details the details
72 public AAIException(String code, String details) {
76 this.templateVars = new LinkedList<>();
77 this.errorObject = ErrorLogHelper.getErrorObject(getCode());
78 errorObject.setDetails(details);
82 * Instantiates a new AAI exception.
84 * @param code the code
85 * @param cause the cause
87 public AAIException(String code, Throwable cause) {
91 this.templateVars = new LinkedList<>();
92 this.errorObject = ErrorLogHelper.getErrorObject(getCode());
96 * Instantiates a new AAI exception.
98 * @param code the code
99 * @param cause the cause
100 * @param details the details
102 public AAIException(String code, Throwable cause, String details) {
103 super(details, cause);
106 this.templateVars = new LinkedList<>();
107 this.errorObject = ErrorLogHelper.getErrorObject(getCode());
110 public String getCode() {
114 public ErrorObject getErrorObject() {
118 public Collection<String> getTemplateVars() {