View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.lang3.concurrent;
18  
19  /**
20   * <p>
21   * An exception class used for reporting runtime error conditions related to
22   * accessing data of background tasks.
23   * </p>
24   * <p>
25   * This class is an analogon of the {@link ConcurrentException} exception class.
26   * However, it is a runtime exception and thus does not need explicit catch
27   * clauses. Some methods of {@link ConcurrentUtils} throw {@code
28   * ConcurrentRuntimeException} exceptions rather than
29   * {@link ConcurrentException} exceptions. They can be used by client code that
30   * does not want to be bothered with checked exceptions.
31   * </p>
32   *
33   * @since 3.0
34   * @version $Id: ConcurrentRuntimeException.java 1436768 2013-01-22 07:07:42Z ggregory $
35   */
36  public class ConcurrentRuntimeException extends RuntimeException {
37      /**
38       * The serial version UID.
39       */
40      private static final long serialVersionUID = -6582182735562919670L;
41  
42      /**
43       * Creates a new, uninitialized instance of {@code
44       * ConcurrentRuntimeException}.
45       */
46      protected ConcurrentRuntimeException() {
47          super();
48      }
49  
50      /**
51       * Creates a new instance of {@code ConcurrentRuntimeException} and
52       * initializes it with the given cause.
53       *
54       * @param cause the cause of this exception
55       * @throws IllegalArgumentException if the cause is not a checked exception
56       */
57      public ConcurrentRuntimeException(final Throwable cause) {
58          super(ConcurrentUtils.checkedException(cause));
59      }
60  
61      /**
62       * Creates a new instance of {@code ConcurrentRuntimeException} and
63       * initializes it with the given message and cause.
64       *
65       * @param msg the error message
66       * @param cause the cause of this exception
67       * @throws IllegalArgumentException if the cause is not a checked exception
68       */
69      public ConcurrentRuntimeException(final String msg, final Throwable cause) {
70          super(msg, ConcurrentUtils.checkedException(cause));
71      }
72  }