redo the error handling due to the changes in DebugStackState made by James
This commit is contained in:
@@ -65,7 +65,8 @@ public class DebugStackState extends StackState implements DebugRequestListener
|
|||||||
protected boolean suspended = false;
|
protected boolean suspended = false;
|
||||||
protected int lastline = -1;
|
protected int lastline = -1;
|
||||||
protected String lastSource;
|
protected String lastSource;
|
||||||
protected DebugSupport debugSupport = null;
|
protected DebugSupport debugSupport;
|
||||||
|
protected VMException lastException;
|
||||||
|
|
||||||
|
|
||||||
public DebugStackState() {}
|
public DebugStackState() {}
|
||||||
@@ -112,26 +113,21 @@ public class DebugStackState extends StackState implements DebugRequestListener
|
|||||||
error(message, 1);
|
error(message, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printLuaTrace() {
|
|
||||||
System.out.println( "Lua location: "+getFileLine(cc) );
|
|
||||||
for ( int cindex=cc-1; cindex>=0; cindex-- )
|
|
||||||
System.out.println( "\tin "+getFileLine( cindex ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
// intercept exceptions and fill in line numbers
|
// intercept exceptions and fill in line numbers
|
||||||
public void exec() {
|
public void exec() {
|
||||||
try {
|
try {
|
||||||
super.exec();
|
super.exec();
|
||||||
} catch (AbortException e) {
|
} catch ( AbortException e ) {
|
||||||
// ignored. Client aborts the debugging session.
|
// ignored. Client aborts the debugging session.
|
||||||
} catch ( RuntimeException t ) {
|
} catch ( VMException e ) {
|
||||||
// let other exceptions be processed
|
// let VM exceptions be processed
|
||||||
// the same as the base class to minimize differences
|
// the same as the base class to minimize differences
|
||||||
// between the debug and non-debug behavior
|
// between the debug and non-debug behavior
|
||||||
|
throw e;
|
||||||
debugSupport.notifyDebugEvent(new DebugEventError(t.getMessage()));
|
} catch ( Exception e ) {
|
||||||
|
lastException = new VMException(e);
|
||||||
|
debugSupport.notifyDebugEvent(new DebugEventError(e.getMessage()));
|
||||||
suspend();
|
suspend();
|
||||||
throw t;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,6 +205,10 @@ public class DebugStackState extends StackState implements DebugRequestListener
|
|||||||
this.wait();
|
this.wait();
|
||||||
if(DebugUtils.IS_DEBUG)
|
if(DebugUtils.IS_DEBUG)
|
||||||
DebugUtils.println("resuming execution...");
|
DebugUtils.println("resuming execution...");
|
||||||
|
|
||||||
|
if (lastException != null) {
|
||||||
|
throw lastException;
|
||||||
|
}
|
||||||
} catch ( InterruptedException ie ) {
|
} catch ( InterruptedException ie ) {
|
||||||
ie.printStackTrace();
|
ie.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
9
src/main/java/lua/debug/VMException.java
Normal file
9
src/main/java/lua/debug/VMException.java
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package lua.debug;
|
||||||
|
|
||||||
|
public class VMException extends RuntimeException {
|
||||||
|
private static final long serialVersionUID = 7876955153693775429L;
|
||||||
|
|
||||||
|
public VMException(Exception e) {
|
||||||
|
super(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -33,6 +33,7 @@ import lua.addon.luajava.LuaJava;
|
|||||||
import lua.debug.DebugStackState;
|
import lua.debug.DebugStackState;
|
||||||
import lua.debug.DebugSupport;
|
import lua.debug.DebugSupport;
|
||||||
import lua.debug.DebugUtils;
|
import lua.debug.DebugUtils;
|
||||||
|
import lua.debug.VMException;
|
||||||
import lua.io.Closure;
|
import lua.io.Closure;
|
||||||
import lua.io.LoadState;
|
import lua.io.LoadState;
|
||||||
import lua.io.Proto;
|
import lua.io.Proto;
|
||||||
@@ -220,7 +221,11 @@ public class StandardLuaJVM {
|
|||||||
for (int i = 0; i < numOfScriptArgs; i++) {
|
for (int i = 0; i < numOfScriptArgs; i++) {
|
||||||
vargs[i] = new LString(args[i]);
|
vargs[i] = new LString(args[i]);
|
||||||
}
|
}
|
||||||
getDebugState().doCall(c, vargs);
|
try {
|
||||||
|
getDebugState().doCall(c, vargs);
|
||||||
|
} catch (VMException e) {
|
||||||
|
System.err.println("VMException: " + e.getMessage());
|
||||||
|
}
|
||||||
getDebugState().stop();
|
getDebugState().stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user