001: /*
002: * Project: AMODA - Abstract Modeled Application
003: * Class: de.gulden.framework.amoda.generic.interaction.GenericErrorMessage
004: * Version: snapshot-beautyj-1.1
005: *
006: * Date: 2004-09-29
007: *
008: * This is a snapshot version of the AMODA 0.2 development branch,
009: * it is not released as a seperate version.
010: * For AMODA, see http://amoda.berlios.de/.
011: *
012: * This is licensed under the GNU Lesser General Public License (LGPL)
013: * and comes with NO WARRANTY.
014: *
015: * Author: Jens Gulden
016: * Email: amoda@jensgulden.de
017: */
018:
019: package de.gulden.framework.amoda.generic.interaction;
020:
021: import de.gulden.framework.amoda.generic.option.*;
022: import de.gulden.framework.amoda.model.interaction.ErrorMessage;
023: import java.lang.*;
024: import java.util.*;
025:
026: /**
027: * Class GenericErrorMessage.
028: *
029: * @author Jens Gulden
030: * @version snapshot-beautyj-1.1
031: */
032: public class GenericErrorMessage extends GenericLogMessage implements
033: ErrorMessage {
034:
035: // ------------------------------------------------------------------------
036: // --- fields ---
037: // ------------------------------------------------------------------------
038:
039: public boolean exit;
040:
041: protected volatile Throwable cause;
042:
043: // ------------------------------------------------------------------------
044: // --- constructor ---
045: // ------------------------------------------------------------------------
046:
047: public GenericErrorMessage() {
048: setType(ERROR_MESSAGE);
049: }
050:
051: // ------------------------------------------------------------------------
052: // --- methods ---
053: // ------------------------------------------------------------------------
054:
055: public void perform() {
056: ((de.gulden.framework.amoda.generic.core.GenericApplicationEnvironment) getApplication()
057: .getEnvironment()).doErrorMessage(this );
058: }
059:
060: public Throwable getCause() {
061: return cause;
062: }
063:
064: public void setCause(Throwable _cause) {
065: cause = _cause;
066: }
067:
068: public boolean exitApplication() {
069: return exit;
070: }
071:
072: public void setExitApplication(boolean _exit) {
073: exit = _exit;
074: }
075:
076: public String toString() {
077: String s = "";
078: if (getText() != null) {
079: s += getText();
080: }
081: if (getCause() != null) {
082: s += getCause().getClass().getName() + ": "
083: + getCause().getMessage() + "\n";
084: java.io.StringWriter sw = new java.io.StringWriter();
085: getCause().printStackTrace(new java.io.PrintWriter(sw));
086: s += sw.toString() + "\n";
087: if (getCause() instanceof de.gulden.util.xml.XMLException) {
088: Throwable wrapped = ((de.gulden.util.xml.XMLException) getCause())
089: .getWrappedThrowable();
090: if (wrapped != null) {
091: s += "*** WRAPPED EXCEPTION ***\n";
092: s += wrapped.getClass().getName() + ": "
093: + wrapped.getMessage() + "\n";
094: sw = new java.io.StringWriter();
095: wrapped
096: .printStackTrace(new java.io.PrintWriter(sw));
097: s += sw.toString() + "\n";
098: }
099: }
100: }
101: if (s.equals("")) {
102: s = "Unknown Error";
103: }
104: return s;
105: }
106:
107: } // end GenericErrorMessage
|