001/*
002 * Copyright (C) 2011 The Guava Authors
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package com.google.common.util.concurrent;
018
019import com.google.common.annotations.GwtCompatible;
020
021import javax.annotation.Nullable;
022
023/**
024 * Unchecked variant of {@link java.util.concurrent.ExecutionException}. As with
025 * {@code ExecutionException}, the exception's {@linkplain #getCause() cause}
026 * comes from a failed task, possibly run in another thread.
027 *
028 * <p>{@code UncheckedExecutionException} is intended as an alternative to
029 * {@code ExecutionException} when the exception thrown by a task is an
030 * unchecked exception. However, it may also wrap a checked exception in some
031 * cases.
032 *
033 * <p>When wrapping an {@code Error} from another thread, prefer {@link
034 * ExecutionError}. When wrapping a checked exception, prefer {@code
035 * ExecutionException}.
036 *
037 * @author Charles Fry
038 * @since 10.0
039 */
040@GwtCompatible
041public class UncheckedExecutionException extends RuntimeException {
042  /**
043   * Creates a new instance with {@code null} as its detail message.
044   */
045  protected UncheckedExecutionException() {}
046
047  /**
048   * Creates a new instance with the given detail message.
049   */
050  protected UncheckedExecutionException(@Nullable String message) {
051    super(message);
052  }
053
054  /**
055   * Creates a new instance with the given detail message and cause.
056   */
057  public UncheckedExecutionException(@Nullable String message, @Nullable Throwable cause) {
058    super(message, cause);
059  }
060
061  /**
062   * Creates a new instance with the given cause.
063   */
064  public UncheckedExecutionException(@Nullable Throwable cause) {
065    super(cause);
066  }
067
068  private static final long serialVersionUID = 0;
069}