Add new cds-access-api proxies
[controller.git] / opendaylight / md-sal / cds-access-api / src / main / java / org / opendaylight / controller / cluster / access / concepts / RequestException.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.cluster.access.concepts;
9
10 import static java.util.Objects.requireNonNull;
11
12 import org.eclipse.jdt.annotation.NonNull;
13
14 /**
15  * A failure cause behind a {@link RequestFailure} to process a {@link Request}.
16  */
17 public abstract class RequestException extends Exception {
18     @java.io.Serial
19     private static final long serialVersionUID = 1L;
20
21     protected RequestException(final @NonNull String message) {
22         super(requireNonNull(message));
23     }
24
25     protected RequestException(final @NonNull String message, final @NonNull Throwable cause) {
26         super(requireNonNull(message), requireNonNull(cause));
27     }
28
29     public abstract boolean isRetriable();
30
31     /**
32      * Unwraps the underlying failure. This method is overridden only in {@link RuntimeRequestException}.
33      *
34      * @return Underlying cause of the failure if exception is a {@link RuntimeRequestException}, or the exception
35      *         itself.
36      */
37     public Throwable unwrap() {
38         return this;
39     }
40 }