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