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;
25 import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
27 public abstract class ApiException extends Exception {
31 private static final long serialVersionUID = 683162058616691134L;
32 private int httpResponseCode;
33 private String messageID;
34 private ErrorLoggerInfo errorLoggerInfo;
36 private List<String> variables;
38 public ApiException(Builder builder) {
39 super(builder.message, builder.cause);
41 this.httpResponseCode = builder.httpResponseCode;
42 this.messageID = builder.messageID;
43 this.variables = builder.variables;
44 this.errorLoggerInfo = builder.errorLoggerInfo;
45 this.variables = builder.variables;
48 public ApiException(String message, Throwable cause) {
49 super(message, cause);
52 public String getMessageID() {
56 public int getHttpResponseCode() {
57 return httpResponseCode;
60 public ErrorLoggerInfo getErrorLoggerInfo() {
61 return errorLoggerInfo;
65 public List<String> getVariables() {
69 public static class Builder<T extends Builder<T>> {
70 private String message;
71 private Throwable cause = null;
72 private int httpResponseCode;
73 private String messageID;
74 private ErrorLoggerInfo errorLoggerInfo = null;
76 private List<String> variables = null;
78 public Builder(String message, int httpResponseCode, String messageID) {
79 this.message = message;
80 this.httpResponseCode = httpResponseCode;
81 this.messageID = messageID;
84 public T message(String message) {
85 this.message = message;
89 public T cause(Throwable cause) {
94 public T httpResponseCode(int httpResponseCode) {
95 this.httpResponseCode = httpResponseCode;
99 public T messageID(String messageID) {
100 this.messageID = messageID;
104 public T errorInfo(ErrorLoggerInfo errorLoggerInfo) {
105 this.errorLoggerInfo = errorLoggerInfo;
109 public T variables(List<String> variables) {
110 this.variables = variables;