2323public class JXPathException extends RuntimeException {
2424
2525 private static final long serialVersionUID = 4306409701468017766L ;
26- /** @serial */
27- private final Throwable exception ;
2826
2927 /**
3028 * Create a new {@code JXPathException} with no detail mesage.
3129 */
3230 public JXPathException () {
33- this .exception = null ;
3431 }
3532
3633 /**
@@ -40,38 +37,25 @@ public JXPathException() {
4037 */
4138 public JXPathException (final String msg ) {
4239 super (msg );
43- this .exception = null ;
4440 }
4541
4642 /**
4743 * Create a new {@code JXPathException} with the given {@code Exception} base cause and detail message.
4844 *
4945 * @param msg The detail message.
50- * @param e The exception to be encapsulated in a JXPathException
46+ * @param cause The exception to be encapsulated in a JXPathException
5147 */
52- public JXPathException (final String msg , final Throwable e ) {
53- super (msg );
54- this .exception = e ;
48+ public JXPathException (final String msg , final Throwable cause ) {
49+ super (msg , cause );
5550 }
5651
5752 /**
5853 * Create a new {@code JXPathException} with a given {@code Throwable} base cause of the error.
5954 *
60- * @param e The exception to be encapsulated in a JXPathException.
61- */
62- public JXPathException (final Throwable e ) {
63- super (e .toString ());
64- this .exception = e ;
65- }
66-
67- /**
68- * Same as {@link #getException() getException()}
69- *
70- * @return The encapsulated exception, or null if there is none.
55+ * @param cause The exception to be encapsulated in a JXPathException.
7156 */
72- @ Override
73- public Throwable getCause () {
74- return exception ;
57+ public JXPathException (final Throwable cause ) {
58+ super (cause .toString ());
7559 }
7660
7761 /**
@@ -80,27 +64,7 @@ public Throwable getCause() {
8064 * @return The encapsulated exception, or null if there is none.
8165 */
8266 public Throwable getException () {
83- return exception ;
67+ return super . getCause () ;
8468 }
8569
86- /**
87- * Gets the message (if any) for this error . If there is no message for the exception and there is an encapsulated exception then the message of that
88- * exception will be returned.
89- *
90- * @return The error message.
91- */
92- @ Override
93- public String getMessage () {
94- final String message = super .getMessage ();
95- if (exception == null ) {
96- return message ;
97- }
98- final StringBuilder buf = new StringBuilder ();
99- if (message != null ) {
100- buf .append (message ).append ("; " );
101- }
102- final String eMsg = exception .getMessage ();
103- buf .append (eMsg == null ? exception .getClass ().getName () : eMsg );
104- return buf .toString ();
105- }
10670}
0 commit comments