001: /*
002: * Copyright 2001-2006 C:1 Financial Services GmbH
003: *
004: * This software is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License Version 2.1, as published by the Free Software Foundation.
007: *
008: * This software is distributed in the hope that it will be useful,
009: * but WITHOUT ANY WARRANTY; without even the implied warranty of
010: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
011: * Lesser General Public License for more details.
012: *
013: * You should have received a copy of the GNU Lesser General Public
014: * License along with this library; if not, write to the Free Software
015: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
016: */
017:
018: package de.finix.contelligent.client.remote;
019:
020: public class RemoteActionException extends Exception {
021: private Throwable t = null;
022:
023: /**
024: * Creates a new <code>ContelligentException</code> instance with the
025: * given String as additional message and with a nested
026: * <code>Throwable</code> object.
027: *
028: * @param message
029: * a non-null <code>String</code> value
030: * @param t
031: * a <code>Throwable</code> value
032: */
033: public RemoteActionException(String message, Throwable t) {
034: super (message);
035: this .t = t;
036: }
037:
038: /**
039: * Creates a new <code>ContelligentException</code> instance with no
040: * additional message.
041: */
042: public RemoteActionException() {
043: super ();
044: }
045:
046: /**
047: * Creates a new <code>RemoteActionException</code> instance with no
048: * additional message but with a nested <code>Throwable</code> object.
049: */
050: public RemoteActionException(Throwable t) {
051: super ();
052: this .t = t;
053: }
054:
055: /**
056: * Creates a new <code>RemoteActionException</code> instance with the
057: * given String as additional message.
058: *
059: * @param message
060: * a non-null <code>String</code> value
061: */
062: public RemoteActionException(String message) {
063: this (message, null);
064: }
065:
066: public Throwable getNested() {
067: return t;
068: }
069:
070: /**
071: * Returns the class-name, the message if one was provided at creation time
072: * ot this RemoteActionException instance.
073: *
074: * @return a <code>String</code> value public String toString() { //
075: * create a new StringWriter with 256 chars initial capacity:
076: * StringWriter out = new StringWriter(256);
077: * out.write(this.getClass().getName()); // write actual class-name
078: *
079: * String message = getLocalizedMessage(); if (message!=null) out.write(":
080: * "+message); // append message
081: *
082: * if (t!=null) { out.er
083: * }
084: *
085: * StringBuffer result = new StringBuffer("HlbError["); result.append("code:
086: * "); result.append(code); if (msg!=null) { result.append(",msg: ");
087: * result.append(msg); } result.append(", origin:
088: * "+this.origin().toString()); result.append(", type:
089: * "+this.type().toString()); return result.toString();
090: * // create a new PrintWriter (without autoflush) as a wrapper for the
091: * StringWriter: // PrintWriter pw = new PrintWriter(out, false); // if
092: * (t!=null) // t.printStackTrace(pw); return out.toString(); }
093: */
094:
095: public String toString() {
096: StringBuffer out = new StringBuffer(getClass().getName());
097: String message = getLocalizedMessage();
098: if (message != null)
099: out.append(": " + message); // append message
100:
101: if (t != null) {
102: out.append("\n->embedded exception:" + t);
103: }
104: return out.toString();
105: }
106:
107: public void printStackTrace(java.io.PrintWriter s) {
108: if (t == null) {
109: super.printStackTrace(s);
110: } else {
111: s.println(toString());
112: t.printStackTrace(s);
113: }
114: }
115:
116: }
|