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