1 package org.apache.commons.digester3.plugins;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 /**
23 * Thrown when a bug is detected in the plugins code.
24 * <p>
25 * This class is intended to be used in assertion statements, similar to the way that java 1.4's native assertion
26 * mechanism is used. However there is a difference: when a java 1.4 assertion fails, an AssertionError is thrown, which
27 * is a subclass of Error; here, the PluginAssertionFailure class extends RuntimeException rather than Error.
28 * <p>
29 * This difference in design is because throwing Error objects is not good in a container-based architecture.
30 * <p>
31 * Example:
32 *
33 * <pre>
34 * if ( impossibleCondition )
35 * {
36 * throw new PluginAssertionFailure( "internal error: impossible condition is true" );
37 * }
38 * </pre>
39 * <p>
40 * Note that PluginAssertionFailure should <i>not</i> be thrown when user input is bad, or when code external to the
41 * Digester module passes invalid parameters to a plugins method. It should be used only in checks for problems which
42 * indicate internal bugs within the plugins module.
43 *
44 * @since 1.6
45 */
46 public class PluginAssertionFailure
47 extends RuntimeException
48 {
49
50 private static final long serialVersionUID = 1L;
51
52 /**
53 * Constructs a new exception with the specified cause.
54 *
55 * @param cause underlying exception that caused this to be thrown
56 */
57 public PluginAssertionFailure( Throwable cause )
58 {
59 super( cause );
60 }
61
62 /**
63 * Constructs a new exception with the specified detail message.
64 *
65 * @param msg describes the reason this exception is being thrown.
66 */
67 public PluginAssertionFailure( String msg )
68 {
69 super( msg );
70 }
71
72 /**
73 * Constructs a new exception with the specified detail message and cause.
74 *
75 * @param msg describes the reason this exception is being thrown.
76 * @param cause underlying exception that caused this to be thrown
77 */
78 public PluginAssertionFailure( String msg, Throwable cause )
79 {
80 super( msg, cause );
81 }
82
83 }