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 = 500;
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 ApiException(String message, int httpResponseCode) {
54 this.httpResponseCode = httpResponseCode;
57 public ApiException(String message) {
61 public String getMessageID() {
65 public int getHttpResponseCode() {
66 return httpResponseCode;
69 public ErrorLoggerInfo getErrorLoggerInfo() {
70 return errorLoggerInfo;
74 public List<String> getVariables() {
78 public static class Builder<T extends Builder<T>> {
79 private String message;
80 private Throwable cause = null;
81 private int httpResponseCode;
82 private String messageID;
83 private ErrorLoggerInfo errorLoggerInfo = null;
85 private List<String> variables = null;
87 public Builder(String message, int httpResponseCode, String messageID) {
88 this.message = message;
89 this.httpResponseCode = httpResponseCode;
90 this.messageID = messageID;
93 public T message(String message) {
94 this.message = message;
98 public T cause(Throwable cause) {
103 public T httpResponseCode(int httpResponseCode) {
104 this.httpResponseCode = httpResponseCode;
108 public T messageID(String messageID) {
109 this.messageID = messageID;
113 public T errorInfo(ErrorLoggerInfo errorLoggerInfo) {
114 this.errorLoggerInfo = errorLoggerInfo;
118 public T variables(List<String> variables) {
119 this.variables = variables;