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 /** 035 * The serial version UID. 036 */ 037 private static final long serialVersionUID = 6622707671812226130L; 038 039 /** 040 * Creates a new, uninitialized instance of {@link ConcurrentException}. 041 */ 042 protected ConcurrentException() { 043 } 044 045 /** 046 * Constructs a new exception with the specified detail message. The cause is not initialized, and may subsequently be initialized by a call to 047 * {@link #initCause}. 048 * 049 * @param message the detail message. The detail message is saved for later retrieval by the {@link #getMessage()} method. 050 * @since 3.19.0 051 */ 052 public ConcurrentException(final String message) { 053 super(message); 054 } 055 056 /** 057 * Creates a new instance of {@link ConcurrentException} and initializes it 058 * with the given message and cause. 059 * 060 * @param msg the error message 061 * @param cause the cause of this exception 062 * @throws IllegalArgumentException if the cause is not a checked exception 063 */ 064 public ConcurrentException(final String msg, final Throwable cause) { 065 super(msg, ConcurrentUtils.checkedException(cause)); 066 } 067 068 /** 069 * Creates a new instance of {@link ConcurrentException} and initializes it 070 * with the given cause. 071 * 072 * @param cause the cause of this exception 073 * @throws IllegalArgumentException if the cause is not a checked exception 074 */ 075 public ConcurrentException(final Throwable cause) { 076 super(ConcurrentUtils.checkedException(cause)); 077 } 078}