1
2
3
4
5
6
7
8
9
10
11
12
13
14
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);
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);
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 }