From 78875ea8e1cc6ba519cd36830c7942e3b688d5d6 Mon Sep 17 00:00:00 2001 From: hns Date: Fri, 22 Nov 2002 19:04:44 +0000 Subject: [PATCH] Scripting exception can now wrap the original exception. --- src/helma/scripting/ScriptingException.java | 81 ++++++++++++--------- 1 file changed, 48 insertions(+), 33 deletions(-) diff --git a/src/helma/scripting/ScriptingException.java b/src/helma/scripting/ScriptingException.java index d738013b..4cedd7ff 100644 --- a/src/helma/scripting/ScriptingException.java +++ b/src/helma/scripting/ScriptingException.java @@ -1,52 +1,67 @@ // ScriptingException.java // Copyright (c) Hannes Wallnöfer 1998-2001 - + package helma.scripting; +import java.io.PrintWriter; +import java.io.PrintStream; + /** * The base class for exceptions thrown by Helma scripting package */ public class ScriptingException extends Exception { + Exception wrapped; + /** * Construct a ScriptingException given an error message */ public ScriptingException (String msg) { super (msg); + wrapped = null; } + /** + * Construct a ScriptingException given an error message + */ + public ScriptingException (Exception w) { + wrapped = w; + } + + public String toString () { + if (wrapped == null) + return super.toString (); + else + return wrapped.toString (); + } + + public String getMessage () { + if (wrapped == null) + return super.getMessage (); + else + return wrapped.getMessage (); + } + + public void printStackTrace () { + if (wrapped == null) + super.printStackTrace (); + else + wrapped.printStackTrace (); + } + + public void printStackTrace (PrintStream stream) { + if (wrapped == null) + super.printStackTrace (stream); + else + wrapped.printStackTrace (stream); + } + + public void printStackTrace (PrintWriter writer) { + if (wrapped == null) + super.printStackTrace (writer); + else + wrapped.printStackTrace (writer); + } } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -