    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 *      http://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     * Creates a new instance of {@link ConcurrentException} and initializes it
    046     * with the given message and cause.
    047     *
    048     * @param msg the error message
    049     * @param cause the cause of this exception
    050     * @throws IllegalArgumentException if the cause is not a checked exception
    051     */
    052    public ConcurrentException(final String msg, final Throwable cause) {
    053        super(msg, ConcurrentUtils.checkedException(cause));
    054    }
    055
    056    /**
    057     * Creates a new instance of {@link ConcurrentException} and initializes it
    058     * with the given cause.
    059     *
    060     * @param cause the cause of this exception
    061     * @throws IllegalArgumentException if the cause is not a checked exception
    062     */
    063    public ConcurrentException(final Throwable cause) {
    064        super(ConcurrentUtils.checkedException(cause));
    065    }
    066}