BUG-5280: unwrap RuntimeRequestExceptions
[controller.git] / opendaylight / md-sal / cds-access-api / src / main / java / org / opendaylight / controller / cluster / access / concepts / RequestException.java
index f3b3d734212ed5daab539f07dff0bb242ed30a7b..4f2a0585da76c9afe04b0a5c744faf4c22138eba 100644 (file)
@@ -24,9 +24,19 @@ public abstract class RequestException extends Exception {
         super(Preconditions.checkNotNull(message));
     }
 
-    protected RequestException(@Nonnull final String message, @Nonnull final Exception cause) {
+    protected RequestException(@Nonnull final String message, @Nonnull final Throwable cause) {
         super(Preconditions.checkNotNull(message), Preconditions.checkNotNull(cause));
     }
 
     public abstract boolean isRetriable();
+
+    /**
+     * Unwraps the underlying failure. This method is overridden only in {@link RuntimeRequestException}.
+     *
+     * @return Underlying cause of the failure if exception is a {@link RuntimeRequestException}, or the exception
+     *         itself.
+     */
+    public Throwable unwrap() {
+        return this;
+    }
 }