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.toWs;
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 GenerationFault 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.
30       *
31       * @serial
32       */
33      public Throwable detail;
34  
35      private GenerationFault(Exception e) {
36          initCause(null); // Disallow subsequent initCause
37          setStackTrace(e.getStackTrace());
38          detail = e;
39      }
40  
41      public GenerationFault(String message) {
42          super(message);
43      }
44  
45      /***
46       * Constructs a <code>Exception</code> with the specified
47       * detail message and nested exception.
48       *
49       * @param s  the detail message
50       * @param ex the nested exception
51       */
52      public GenerationFault(String s, Throwable ex) {
53          initCause(null); // Disallow subsequent initCause
54          detail = ex;
55          setStackTrace(ex.getStackTrace());
56      }
57  
58      /***
59       * Returns the detail message, including the message from the nested
60       * exception if there is one.
61       *
62       * @return	the detail message, including nested exception message if any
63       */
64      public String getMessage() {
65          if (detail == null) {
66              return super.getMessage();
67          } else {
68              return detail.getMessage();
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  
81      public static GenerationFault createGenerationFault(Exception e) {
82          if (e instanceof GenerationFault) {
83              return (GenerationFault) e;
84          } else
85              return new GenerationFault(e);
86      }
87  }