* merge with HEAD
diff --git a/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/dbgp/exceptions/DbgpDebuggingEngineException.java b/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/dbgp/exceptions/DbgpDebuggingEngineException.java
index 3f148a7..9a25729 100644
--- a/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/dbgp/exceptions/DbgpDebuggingEngineException.java
+++ b/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/dbgp/exceptions/DbgpDebuggingEngineException.java
@@ -102,7 +102,7 @@
 	}
 
 	public DbgpDebuggingEngineException(int code, String message) {
-		super(message + ", code = " + code);
+		super("Execution error:" + code +"\n" + message);
 		this.code = code;
 	}
 
diff --git a/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptThread.java b/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptThread.java
index 6da902f..60c78a5 100644
--- a/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptThread.java
+++ b/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptThread.java
@@ -9,6 +9,9 @@
  *******************************************************************************/
 package org.eclipse.dltk.internal.debug.core.model;
 
+import java.io.IOException;
+import java.io.OutputStream;
+
 import org.eclipse.core.runtime.Assert;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.Preferences;
@@ -32,6 +35,7 @@
 import org.eclipse.dltk.debug.core.ISmartStepEvaluator;
 import org.eclipse.dltk.debug.core.eval.IScriptEvaluationEngine;
 import org.eclipse.dltk.debug.core.model.IScriptDebugTarget;
+import org.eclipse.dltk.debug.core.model.IScriptStackFrame;
 import org.eclipse.dltk.debug.core.model.IScriptThread;
 import org.eclipse.dltk.internal.debug.core.eval.ScriptEvaluationEngine;
 import org.eclipse.dltk.internal.debug.core.model.operations.DbgpDebugger;
@@ -114,6 +118,31 @@
 	public void handleTermination(DbgpException e) {
 		if (e != null) {
 			DLTKDebugPlugin.log(e);
+			IScriptDebugTarget scriptDebugTarget = this.getScriptDebugTarget();
+			OutputStream stdout = scriptDebugTarget.getStreamProxy()
+					.getStderr();
+			try {
+				String message = "\n" + e.getMessage() + "\n";
+				stdout.write(message.getBytes());
+				stack.update();
+				IStackFrame[] frames = stack.getFrames();
+				stdout.write("\nStack trace:\n".getBytes());
+				for (int i = 0; i < frames.length; i++) {
+					IScriptStackFrame frame = (IScriptStackFrame) frames[i];
+					String line = "\t#" + frame.getLevel() + " file:"
+							+ frame.getSourceURI().getPath() + " line:"
+							+ frame.getLineNumber() + "\n";
+					stdout.write(line.getBytes());
+				}
+			} catch (IOException e1) {
+				if (DLTKCore.DEBUG) {
+					e1.printStackTrace();
+				}
+			} catch (DebugException e2) {
+				if (DLTKCore.DEBUG) {
+					e.printStackTrace();
+				}
+			}
 		}
 
 		session.requestTermination();
diff --git a/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptThreadStateManager.java b/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptThreadStateManager.java
index 6f65b72..a78ebf9 100644
--- a/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptThreadStateManager.java
+++ b/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptThreadStateManager.java
@@ -2,6 +2,7 @@
 
 import org.eclipse.debug.core.DebugEvent;
 import org.eclipse.debug.core.DebugException;
+import org.eclipse.dltk.core.DLTKCore;
 import org.eclipse.dltk.dbgp.IDbgpStatus;
 import org.eclipse.dltk.dbgp.exceptions.DbgpException;
 import org.eclipse.dltk.internal.debug.core.model.operations.DbgpDebugger;
@@ -40,10 +41,11 @@
 		if (exception != null) {
 			setTerminated(exception);
 		}
-		if( status == null ) {
+		if (status == null) {
 			setTerminated(null);
 			return;
 		}
+
 		if (status.isBreak()) {
 			setSuspended(true, suspendDetail);
 		} else if (status.isStopping()) {
@@ -51,8 +53,9 @@
 			try {
 				terminate();
 			} catch (DebugException e) {
-				// TODO Auto-generated catch block
-				e.printStackTrace();
+				if (DLTKCore.DEBUG) {
+					e.printStackTrace();
+				}
 			}
 		} else if (status.isStopped()) {
 			setTerminated(null);
@@ -127,13 +130,14 @@
 		this.stepIntoState = true;
 		engine.stepInto();
 	}
+
 	public boolean isStepInto() {
 		return this.stepIntoState;
 	}
+
 	public void setStepInto(boolean state) {
 		this.stepIntoState = state;
 	}
-	
 
 	// StepOver
 	public boolean canStepOver() {
@@ -218,6 +222,6 @@
 	}
 
 	public void notifyModified() {
-		modificationsCount++;		
+		modificationsCount++;
 	}
 }
diff --git a/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/operations/DbgpOperation.java b/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/operations/DbgpOperation.java
index 3aea608..59c32e5 100644
--- a/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/operations/DbgpOperation.java
+++ b/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/operations/DbgpOperation.java
@@ -73,7 +73,6 @@
 						System.out.println(e.getClass());
 						e.printStackTrace();
 					}
-
 					resultHandler.finish(null, e);
 				}