diff --git a/README.html b/README.html index c28d45fa..5f853072 100644 --- a/README.html +++ b/README.html @@ -19,7 +19,7 @@ Getting Started with LuaJ James Roseborough, Ian Farmer, Version 3.0-beta2

-Copyright © 2009-2013 Luaj.org. +Copyright © 2009-2014 Luaj.org. Freely available under the terms of the Luaj license. diff --git a/src/core/org/luaj/vm2/LuaClosure.java b/src/core/org/luaj/vm2/LuaClosure.java index c257d386..9581f829 100644 --- a/src/core/org/luaj/vm2/LuaClosure.java +++ b/src/core/org/luaj/vm2/LuaClosure.java @@ -518,26 +518,28 @@ public class LuaClosure extends LuaFunction { * Run the error hook if there is one * @param msg the message to use in error hook processing. * */ - String errorHook(String msg) { + String errorHook(String msg, int level) { if (globals == null ) return msg; - final LuaThread running = globals.running; - if (running == null) return msg; - final LuaValue errfunc = running.errorfunc; - if (errfunc == null) return msg; - running.errorfunc = null; + final LuaThread r = globals.running; + if (r.errorfunc == null) + return globals.debuglib != null? + msg + "\n" + globals.debuglib.traceback(level): + msg; + final LuaValue e = r.errorfunc; + r.errorfunc = null; try { - return errfunc.call( LuaValue.valueOf(msg) ).tojstring(); + return e.call( LuaValue.valueOf(msg) ).tojstring(); } catch ( Throwable t ) { return "error in error handling"; } finally { - running.errorfunc = errfunc; + r.errorfunc = e; } } private void processErrorHooks(LuaError le, Prototype p, int pc) { le.fileline = (p.source != null? p.source.tojstring(): "?") + ":" + (p.lineinfo != null && pc >= 0 && pc < p.lineinfo.length? String.valueOf(p.lineinfo[pc]): "?"); - le.traceback = errorHook(le.getMessage()); + le.traceback = errorHook(le.getMessage(), le.level); } private UpValue findupval(LuaValue[] stack, short idx, UpValue[] openups) {