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     */
017    package 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     * @version $Id: ConcurrentException.java 1088899 2011-04-05 05:31:27Z bayard $
034     */
035    public class ConcurrentException extends Exception {
036        /**
037         * The serial version UID.
038         */
039        private static final long serialVersionUID = 6622707671812226130L;
040    
041        /**
042         * Creates a new, uninitialized instance of {@code ConcurrentException}.
043         */
044        protected ConcurrentException() {
045            super();
046        }
047    
048        /**
049         * Creates a new instance of {@code ConcurrentException} and initializes it
050         * with the given cause.
051         *
052         * @param cause the cause of this exception
053         * @throws IllegalArgumentException if the cause is not a checked exception
054         */
055        public ConcurrentException(Throwable cause) {
056            super(ConcurrentUtils.checkedException(cause));
057        }
058    
059        /**
060         * Creates a new instance of {@code ConcurrentException} and initializes it
061         * with the given message and cause.
062         *
063         * @param msg the error message
064         * @param cause the cause of this exception
065         * @throws IllegalArgumentException if the cause is not a checked exception
066         */
067        public ConcurrentException(String msg, Throwable cause) {
068            super(msg, ConcurrentUtils.checkedException(cause));
069        }
070    }