View Javadoc

1   /*
2    * Copyright 2001-2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.apache.geronimo.ews.ws4j2ee.parsers;
18  
19  /***
20   * <p>This denotes the Exception occured at the code genaration.
21   * There is a isssue of wrapping the Exception such that JDK1.3 compatibility.
22   * This code write same way as it was done at the RemoteException.</p>
23   */
24  public class ParserFault extends Exception {
25      /***
26       * Nested Exception to hold wrapped exception.
27       * <p>This field predates the general-purpose exception chaining facility.
28       * The {@link Throwable#getCause()} method is now the preferred means of
29       * obtaining this information.</p>
30       *
31       * @serial
32       */
33      public Throwable detail;
34  
35      public ParserFault(Exception e) {
36          initCause(null);  // Disallow subsequent initCause
37          detail = e;
38      }
39  
40      public ParserFault(String message) {
41          super(message);
42      }
43  
44      /***
45       * Constructs a <code>Exception</code> with the specified
46       * detail message and nested exception.
47       *
48       * @param s  the detail message
49       * @param ex the nested exception
50       */
51      public ParserFault(String s, Throwable ex) {
52          super(s);
53          initCause(null);  // Disallow subsequent initCause
54          detail = ex;
55      }
56  
57      /***
58       * Returns the detail message, including the message from the nested
59       * exception if there is one.
60       *
61       * @return	the detail message, including nested exception message if any
62       */
63      public String getMessage() {
64          if (detail == null) {
65              return super.getMessage();
66          } else {
67              return super.getMessage() + "; nested exception is: \n\t" +
68                      detail.toString();
69          }
70      }
71  
72      /***
73       * Returns the wrapped exception (the <i>cause</i>).
74       *
75       * @return the wrapped exception, which may be <tt>null</tt>.
76       */
77      public Throwable getCause() {
78          return detail;
79      }
80  }