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 runtime error conditions related to
022 * accessing data of background tasks.
023 * </p>
024 * <p>
025 * This class is an analogon of the {@link ConcurrentException} exception class.
026 * However, it is a runtime exception and thus does not need explicit catch
027 * clauses. Some methods of {@link ConcurrentUtils} throw {@code
028 * ConcurrentRuntimeException} exceptions rather than
029 * {@link ConcurrentException} exceptions. They can be used by client code that
030 * does not want to be bothered with checked exceptions.
031 * </p>
032 *
033 * @since 3.0
034 * @version $Id: ConcurrentRuntimeException.java 1436768 2013-01-22 07:07:42Z ggregory $
035 */
036public class ConcurrentRuntimeException extends RuntimeException {
037    /**
038     * The serial version UID.
039     */
040    private static final long serialVersionUID = -6582182735562919670L;
041
042    /**
043     * Creates a new, uninitialized instance of {@code
044     * ConcurrentRuntimeException}.
045     */
046    protected ConcurrentRuntimeException() {
047        super();
048    }
049
050    /**
051     * Creates a new instance of {@code ConcurrentRuntimeException} and
052     * initializes it with the given cause.
053     *
054     * @param cause the cause of this exception
055     * @throws IllegalArgumentException if the cause is not a checked exception
056     */
057    public ConcurrentRuntimeException(final Throwable cause) {
058        super(ConcurrentUtils.checkedException(cause));
059    }
060
061    /**
062     * Creates a new instance of {@code ConcurrentRuntimeException} and
063     * initializes it with the given message and cause.
064     *
065     * @param msg the error message
066     * @param cause the cause of this exception
067     * @throws IllegalArgumentException if the cause is not a checked exception
068     */
069    public ConcurrentRuntimeException(final String msg, final Throwable cause) {
070        super(msg, ConcurrentUtils.checkedException(cause));
071    }
072}