public abstract class RequestException extends Exception {
private static final long serialVersionUID = 1L;
- protected RequestException(final @Nonnull String message) {
+ protected RequestException(@Nonnull final String message) {
super(Preconditions.checkNotNull(message));
}
- protected RequestException(final @Nonnull String message, final @Nonnull 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;
+ }
}