    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
    019/**
    020 * <p>
    021 * An exception class used for reporting error conditions related to accessing
    022 * data of background tasks.
    023 * </p>
    024 * <p>
    025 * The purpose of this exception class is analogous to the default JDK exception
    026 * class {@link java.util.concurrent.ExecutionException}, i.e. it wraps an
    027 * exception that occurred during the execution of a task. However, in contrast
    028 * to {@code ExecutionException}, it wraps only checked exceptions. Runtime
    029 * exceptions are thrown directly.
    030 * </p>
    031 *
    032 * @since 3.0
    033 */
    034public class ConcurrentException extends Exception {
    035    /**
    036     * The serial version UID.
    037     */
    038    private static final long serialVersionUID = 6622707671812226130L;
    039
    040    /**
    041     * Creates a new, uninitialized instance of {@code ConcurrentException}.
    042     */
    043    protected ConcurrentException() {
    044    }
    045
    046    /**
    047     * Creates a new instance of {@code ConcurrentException} and initializes it
    048     * with the given cause.
    049     *
    050     * @param cause the cause of this exception
    051     * @throws IllegalArgumentException if the cause is not a checked exception
    052     */
    053    public ConcurrentException(final Throwable cause) {
    054        super(ConcurrentUtils.checkedException(cause));
    055    }
    056
    057    /**
    058     * Creates a new instance of {@code ConcurrentException} and initializes it
    059     * with the given message and cause.
    060     *
    061     * @param msg the error message
    062     * @param cause the cause of this exception
    063     * @throws IllegalArgumentException if the cause is not a checked exception
    064     */
    065    public ConcurrentException(final String msg, final Throwable cause) {
    066        super(msg, ConcurrentUtils.checkedException(cause));
    067    }
    068}