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