2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
4 * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
5 * Modifications Copyright (C) 2023 Nordix Foundation.
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.
19 * SPDX-License-Identifier: Apache-2.0
20 * ============LICENSE_END=========================================================
23 package org.onap.policy.api.main.exception;
25 import java.io.Serial;
26 import java.util.UUID;
28 import org.onap.policy.models.errors.concepts.ErrorResponse;
31 * This runtime exception will be called if a runtime error occurs when using policy api.
34 public class PolicyApiRuntimeException extends RuntimeException {
37 private static final long serialVersionUID = -8507246953751956974L;
39 private final UUID requestId;
40 private final ErrorResponse errorResponse;
43 * Instantiates a new policy api runtime exception with a message.
45 * @param message the message
47 public PolicyApiRuntimeException(final String message) {
49 this.requestId = null;
50 this.errorResponse = null;
54 * Instantiates a new policy api runtime exception with a message and a caused by exception.
56 * @param message the message
57 * @param exp the exception that caused this exception to be thrown
59 public PolicyApiRuntimeException(final String message, final Exception exp) {
61 this.requestId = null;
62 this.errorResponse = null;
66 * Instantiates a new policy api runtime exception with requestId, errorResponse object
67 * along with message and a caused by exception.
69 * @param message the message
70 * @param cause the exception that caused this exception to be thrown
71 * @param requestId request identifier
72 * @param errorResponse error response object
74 public PolicyApiRuntimeException(final String message, final Throwable cause,
75 final ErrorResponse errorResponse, final UUID requestId) {
76 super(message, cause);
77 this.requestId = requestId;
78 this.errorResponse = errorResponse;