01: /**
02: * $Id: SimpleWebServiceException.java,v 1.5 2003/06/03 10:44:01 sy131129 Exp $
03: * Copyright 2002-2003 Sun Microsystems, Inc. All
04: * rights reserved. Use of this product is subject
05: * to license terms. Federal Acquisitions:
06: * Commercial Software -- Government Users
07: * Subject to Standard License Terms and
08: * Conditions.
09: *
10: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
11: * are trademarks or registered trademarks of Sun Microsystems,
12: * Inc. in the United States and other countries.
13: */package com.sun.portal.providers.simplewebservice;
14:
15: import java.io.PrintWriter;
16: import java.io.StringWriter;
17:
18: /**
19: * This is the base class of all Simple Web Service related
20: * exceptions. This class is subclassed into more fine grained
21: * subclasses.
22: *
23: * @see SimpleWebServiceProcessException
24: */
25: public class SimpleWebServiceException extends Exception {
26:
27: public static final String FUNCTIONALITY_NOT_SUPPORTED = "FUNCTIONALITY_NOT_SUPPORTED";
28: public static final String WSDL_DESCRIPTOR_ERROR = "WSDL_DESCRIPTOR_ERROR";
29: public static final String UNKNOWN_RUNTIME_ERROR = "UNKNOWN_RUNTIME_ERROR";
30:
31: private Throwable targetThrowable = null;
32: private String faultCode = null;
33:
34: /**
35: * Public Constructor.
36: * <P>
37: *
38: * @param faultCode the SimpleWebServiceException faultCode.
39: * @param message the SimpleWebServiceException message.
40: * @param targetThrowable the target throwable for the SimpleWebServiceException.
41: */
42: public SimpleWebServiceException(String faultCode, String message,
43: Throwable targetThrowable) {
44: super (message);
45: this .faultCode = faultCode;
46: this .targetThrowable = targetThrowable;
47: }
48:
49: /**
50: * Public Constructor.
51: * <P>
52: *
53: * @param faultCode the SimpleWebServiceException faultCode.
54: * @param message the SimpleWebServiceException message.
55: */
56: public SimpleWebServiceException(String faultCode, String message) {
57: this (faultCode, message, null);
58: }
59:
60: /**
61: * Gets the fault code associated with this Exception.
62: * <P>
63: *
64: * @return the fault code.
65: */
66: public String getFaultCode() {
67: return faultCode;
68: }
69:
70: /**
71: * Gets the target Throwable associated with this Exception.
72: * <P>
73: *
74: * @return the target Throwable.
75: */
76: public Throwable getTargetException() {
77: return targetThrowable;
78: }
79:
80: /**
81: * Gets the String representation for this Exception.
82: * <P>
83: *
84: * @return the Exception String representation.
85: */
86: public String toString() {
87: StringWriter sw = new StringWriter();
88: PrintWriter pw = new PrintWriter(sw);
89:
90: pw.print(getMessage() + ": ");
91:
92: if (targetThrowable != null) {
93: targetThrowable.printStackTrace(pw);
94: }
95:
96: return sw.toString();
97: }
98: }
|