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