001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * https://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.lang3.concurrent; 018 019import java.util.concurrent.ExecutionException; 020 021/** 022 * An exception class used for reporting error conditions related to accessing data of background tasks. 023 * 024 * <p> 025 * The purpose of this exception class is analogous to the default JDK exception class {@link ExecutionException}, i.e. 026 * it wraps an exception that occurred during the execution of a task. However, in contrast to 027 * {@link ExecutionException}, it wraps only checked exceptions. Runtime exceptions are thrown directly. 028 * </p> 029 * 030 * @since 3.0 031 */ 032public class ConcurrentException extends Exception { 033 /** 034 * The serial version UID. 035 */ 036 private static final long serialVersionUID = 6622707671812226130L; 037 038 /** 039 * Creates a new, uninitialized instance of {@link ConcurrentException}. 040 */ 041 protected ConcurrentException() { 042 } 043 044 /** 045 * Constructs a new exception with the specified detail message. The cause is not initialized, and may subsequently be initialized by a call to 046 * {@link #initCause}. 047 * 048 * @param message the detail message. The detail message is saved for later retrieval by the {@link #getMessage()} method. 049 * @since 3.19.0 050 */ 051 public ConcurrentException(final String message) { 052 super(message); 053 } 054 055 /** 056 * Creates a new instance of {@link ConcurrentException} and initializes it 057 * with the given message and cause. 058 * 059 * @param msg the error message 060 * @param cause the cause of this exception 061 * @throws IllegalArgumentException if the cause is not a checked exception 062 */ 063 public ConcurrentException(final String msg, final Throwable cause) { 064 super(msg, ConcurrentUtils.checkedException(cause)); 065 } 066 067 /** 068 * Creates a new instance of {@link ConcurrentException} and initializes it 069 * with the given cause. 070 * 071 * @param cause the cause of this exception 072 * @throws IllegalArgumentException if the cause is not a checked exception 073 */ 074 public ConcurrentException(final Throwable cause) { 075 super(ConcurrentUtils.checkedException(cause)); 076 } 077}