View Javadoc
1   /*
2    * Copyright (C) 2011 The Guava Authors
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5    * in compliance with the License. You may obtain a copy of the License at
6    *
7    * http://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software distributed under the License
10   * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11   * or implied. See the License for the specific language governing permissions and limitations under
12   * the License.
13   */
14  
15  package com.google.common.util.concurrent;
16  
17  import com.google.common.annotations.GwtCompatible;
18  import javax.annotation.Nullable;
19  
20  /**
21   * Unchecked variant of {@link java.util.concurrent.ExecutionException}. As with
22   * {@code ExecutionException}, the exception's {@linkplain #getCause() cause} comes from a failed
23   * task, possibly run in another thread.
24   *
25   * <p>{@code UncheckedExecutionException} is intended as an alternative to
26   * {@code ExecutionException} when the exception thrown by a task is an unchecked exception.
27   * However, it may also wrap a checked exception in some cases.
28   *
29   * <p>When wrapping an {@code Error} from another thread, prefer {@link ExecutionError}. When
30   * wrapping a checked exception, prefer {@code
31   * ExecutionException}.
32   *
33   * @author Charles Fry
34   * @since 10.0
35   */
36  @GwtCompatible
37  public class UncheckedExecutionException extends RuntimeException {
38    /**
39     * Creates a new instance with {@code null} as its detail message.
40     */
41    protected UncheckedExecutionException() {}
42  
43    /**
44     * Creates a new instance with the given detail message.
45     */
46    protected UncheckedExecutionException(@Nullable String message) {
47      super(message);
48    }
49  
50    /**
51     * Creates a new instance with the given detail message and cause.
52     */
53    public UncheckedExecutionException(@Nullable String message, @Nullable Throwable cause) {
54      super(message, cause);
55    }
56  
57    /**
58     * Creates a new instance with the given cause.
59     */
60    public UncheckedExecutionException(@Nullable Throwable cause) {
61      super(cause);
62    }
63  
64    private static final long serialVersionUID = 0;
65  }