01: /**
02: * $Id: ProducerError.java,v 1.1 2004/02/24 00:41:05 jtb Exp $
03: * Copyright 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.wsrp.producer;
14:
15: import java.io.PrintWriter;
16: import java.io.StringWriter;
17:
18: public class ProducerError extends Error {
19: private Throwable _targetThrowable = null;
20: private int _errorCode = 0;
21:
22: public ProducerError(Throwable targetThrowable) {
23: super ();
24: _targetThrowable = targetThrowable;
25: }
26:
27: public ProducerError(String message, Throwable targetThrowable) {
28: super (message);
29: _targetThrowable = targetThrowable;
30: }
31:
32: public ProducerError(String message) {
33: this (message, null);
34: }
35:
36: public ProducerError(int errorCode, String message) {
37: this (message, null);
38: _errorCode = errorCode;
39: }
40:
41: public Throwable getTargetException() {
42: return _targetThrowable;
43: }
44:
45: public int getErrorCode() {
46: return _errorCode;
47: }
48:
49: public String toString() {
50: StringWriter sw = new StringWriter();
51: PrintWriter pw = new PrintWriter(sw);
52:
53: pw.print(getMessage() + ": ");
54:
55: if (_errorCode != 0) {
56: pw.print("Error Code: " + _errorCode);
57: }
58:
59: if (_targetThrowable != null) {
60: _targetThrowable.printStackTrace(pw);
61: }
62:
63: return sw.toString();
64: }
65: }
|