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