• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.CheckForNull;
19 
20 /**
21  * {@link Error} variant of {@link java.util.concurrent.ExecutionException}. As with {@code
22  * ExecutionException}, the error's {@linkplain #getCause() cause} comes from a failed task,
23  * possibly run in another thread. That cause should itself be an {@code Error}; if not, use {@code
24  * ExecutionException} or {@link UncheckedExecutionException}. This allows the client code to
25  * continue to distinguish between exceptions and errors, even when they come from other threads.
26  *
27  * @author Chris Povirk
28  * @since 10.0
29  */
30 @GwtCompatible
31 @ElementTypesAreNonnullByDefault
32 public class ExecutionError extends Error {
33   /*
34    * Ideally, this class would have exposed only constructors that require a non-null cause. We
35    * might try to move in that direction, but there are complications. See
36    * https://github.com/jspecify/jspecify-reference-checker/blob/61aafa4ae52594830cfc2d61c8b113009dbdb045/src/main/java/com/google/jspecify/nullness/NullSpecTransfer.java#L789
37    */
38 
39   /** Creates a new instance with {@code null} as its detail message. */
ExecutionError()40   protected ExecutionError() {}
41 
42   /** Creates a new instance with the given detail message. */
ExecutionError(@heckForNull String message)43   protected ExecutionError(@CheckForNull String message) {
44     super(message);
45   }
46 
47   /** Creates a new instance with the given detail message and cause. */
ExecutionError(@heckForNull String message, @CheckForNull Error cause)48   public ExecutionError(@CheckForNull String message, @CheckForNull Error cause) {
49     super(message, cause);
50   }
51 
52   /** Creates a new instance with the given cause. */
ExecutionError(@heckForNull Error cause)53   public ExecutionError(@CheckForNull Error cause) {
54     super(cause);
55   }
56 
57   private static final long serialVersionUID = 0;
58 }
59