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
017 package com.google.common.util.concurrent;
018
019 import com.google.common.annotations.Beta;
020
021 /**
022 * Unchecked variant of {@link java.util.concurrent.ExecutionException}. As with
023 * {@code ExecutionException}, the exception's {@linkplain #getCause() cause}
024 * comes from a failed task, possibly run in another thread.
025 *
026 * <p>{@code UncheckedExecutionException} is intended as an alternative to
027 * {@code ExecutionException} when the exception thrown by a task is an
028 * unchecked exception. This allows the client code to continue to distinguish
029 * between checked and unchecked exceptions, even when they come from other
030 * threads.
031 *
032 * <p>When wrapping an {@code Error} from another thread, prefer {@link
033 * ExecutionError}.
034 *
035 * @author Charles Fry
036 * @since 10.0
037 */
038 @Beta
039 public class UncheckedExecutionException extends RuntimeException {
040 /**
041 * Creates a new instance with {@code null} as its detail message.
042 */
043 protected UncheckedExecutionException() {}
044
045 /**
046 * Creates a new instance with the given detail message.
047 */
048 protected UncheckedExecutionException(String message) {
049 super(message);
050 }
051
052 /**
053 * Creates a new instance with the given detail message and cause.
054 */
055 public UncheckedExecutionException(String message, Throwable cause) {
056 super(message, cause);
057 }
058
059 /**
060 * Creates a new instance with the given cause.
061 */
062 public UncheckedExecutionException(Throwable cause) {
063 super(cause);
064 }
065
066 private static final long serialVersionUID = 0;
067 }