01: package com.sun.portal.wsrp.producer;
02:
03: import java.io.PrintWriter;
04: import java.io.StringWriter;
05:
06: public class ProducerException extends Exception {
07:
08: private Throwable _targetThrowable = null;
09: private int _errorCode = 0;
10:
11: public ProducerException(Throwable targetThrowable) {
12: super ();
13: _targetThrowable = targetThrowable;
14: }
15:
16: public ProducerException(String message, Throwable targetThrowable) {
17: super (message);
18: _targetThrowable = targetThrowable;
19: }
20:
21: public ProducerException(String message) {
22: this (message, null);
23: }
24:
25: public ProducerException(int errorCode, String message) {
26: this (message, null);
27: _errorCode = errorCode;
28: }
29:
30: public Throwable getTargetException() {
31: return _targetThrowable;
32: }
33:
34: public int getErrorCode() {
35: return _errorCode;
36: }
37:
38: public String toString() {
39: StringWriter sw = new StringWriter();
40: PrintWriter pw = new PrintWriter(sw);
41:
42: pw.print(getMessage() + ": ");
43:
44: if (_errorCode != 0) {
45: pw.print("Error Code: " + _errorCode);
46: }
47:
48: if (_targetThrowable != null) {
49: _targetThrowable.printStackTrace(pw);
50: }
51:
52: return sw.toString();
53: }
54: }
|