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.onap.so.apihandlerinfra.exceptions;
24 import java.util.List;
27 import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
29 public abstract class ApiException extends Exception{
33 private static final long serialVersionUID = 683162058616691134L;
34 private int httpResponseCode;
35 private String messageID;
36 private ErrorLoggerInfo errorLoggerInfo;
38 private List<String> variables;
40 public ApiException(Builder builder){
41 super(builder.message, builder.cause);
43 this.httpResponseCode = builder.httpResponseCode;
44 this.messageID = builder.messageID;
45 this.variables = builder.variables;
46 this.errorLoggerInfo = builder.errorLoggerInfo;
47 this.variables = builder.variables;
50 public ApiException(String message, Throwable cause) {
51 super(message, cause);
54 public String getMessageID() {
58 public int getHttpResponseCode() {
59 return httpResponseCode;
62 public ErrorLoggerInfo getErrorLoggerInfo() {
63 return errorLoggerInfo;
67 public List<String> getVariables() {
71 public static class Builder<T extends Builder<T>> {
72 private String message;
73 private Throwable cause = null;
74 private int httpResponseCode;
75 private String messageID;
76 private ErrorLoggerInfo errorLoggerInfo = null;
78 private List<String> variables = null;
80 public Builder(String message, int httpResponseCode, String messageID) {
81 this.message = message;
82 this.httpResponseCode = httpResponseCode;
83 this.messageID = messageID;
86 public T message(String message) {
87 this.message = message;
91 public T cause(Throwable cause) {
96 public T httpResponseCode(int httpResponseCode) {
97 this.httpResponseCode = httpResponseCode;
101 public T messageID(String messageID) {
102 this.messageID = messageID;
106 public T errorInfo(ErrorLoggerInfo errorLoggerInfo){
107 this.errorLoggerInfo = errorLoggerInfo;
111 public T variables(List<String> variables) {
112 this.variables = variables;