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: import java.io.PrintWriter;
021:
022: public class IncompatibleServerException extends Exception {
023: private Throwable t = null;
024:
025: /**
026: * Creates a new <code>ContelligentException</code> instance with the
027: * given String as additional message and with a nested
028: * <code>Throwable</code> object.
029: *
030: * @param message
031: * a non-null <code>String</code> value
032: * @param t
033: * a <code>Throwable</code> value
034: */
035: public IncompatibleServerException(String message, Throwable t) {
036: super (message);
037: this .t = t;
038: }
039:
040: /**
041: * Creates a new <code>ContelligentException</code> instance with no
042: * additional message.
043: */
044: public IncompatibleServerException() {
045: super ();
046: }
047:
048: /**
049: * Creates a new <code>RemoteActionException</code> instance with no
050: * additional message but with a nested <code>Throwable</code> object.
051: */
052: public IncompatibleServerException(Throwable t) {
053: super ();
054: this .t = t;
055: }
056:
057: /**
058: * Creates a new <code>RemoteActionException</code> instance with the
059: * given String as additional message.
060: *
061: * @param message
062: * a non-null <code>String</code> value
063: */
064: public IncompatibleServerException(String message) {
065: this (message, null);
066: }
067:
068: public Throwable getNested() {
069: return t;
070: }
071:
072: /**
073: * Returns the class-name, the message if one was provided at creation time
074: * ot this RemoteActionException instance.
075: *
076: * @return a <code>String</code> value public String toString() { //
077: * create a new StringWriter with 256 chars initial capacity:
078: * StringWriter out = new StringWriter(256);
079: * out.write(this.getClass().getName()); // write actual class-name
080: *
081: * String message = getLocalizedMessage(); if (message!=null) out.write(":
082: * "+message); // append message
083: *
084: * if (t!=null) { out.er
085: * }
086: *
087: * StringBuffer result = new StringBuffer("HlbError["); result.append("code:
088: * "); result.append(code); if (msg!=null) { result.append(",msg: ");
089: * result.append(msg); } result.append(", origin:
090: * "+this.origin().toString()); result.append(", type:
091: * "+this.type().toString()); return result.toString();
092: * // create a new PrintWriter (without autoflush) as a wrapper for the
093: * StringWriter: // PrintWriter pw = new PrintWriter(out, false); // if
094: * (t!=null) // t.printStackTrace(pw); return out.toString(); }
095: */
096:
097: public String toString() {
098: StringBuffer out = new StringBuffer(getClass().getName());
099: String message = getLocalizedMessage();
100: if (message != null)
101: out.append(": " + message); // append message
102:
103: if (t != null) {
104: out.append("\n->embedded exception:" + t);
105: }
106: return out.toString();
107: }
108:
109: public void printStackTrace(PrintWriter s) {
110: if (t == null) {
111: super.printStackTrace(s);
112: } else {
113: s.println(toString());
114: t.printStackTrace(s);
115: }
116: }
117:
118: }
|