From d6c1d1aee64aae2006892e87c4f98cf2325dc301 Mon Sep 17 00:00:00 2001 From: pixel Date: Mon, 13 Dec 2004 20:07:09 +0000 Subject: Adding better debug context. --- lib/BLua.cc | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/BLua.cc b/lib/BLua.cc index 51a5e97..60cf4f2 100644 --- a/lib/BLua.cc +++ b/lib/BLua.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: BLua.cc,v 1.22 2004-11-27 21:46:04 pixel Exp $ */ +/* $Id: BLua.cc,v 1.23 2004-12-13 20:07:09 pixel Exp $ */ #include "BLua.h" #include @@ -353,7 +353,26 @@ int Lua::gettop() { } void Lua::error(const String & msg) { + String whole_msg; + struct lua_Debug ar; + bool got_error = false; + int level = 0; + + do { + if (lua_getstack(L, level, &ar) == 1) { + if (lua_getinfo(L, "nSl", &ar) != 0) { + push(String("at ") + ar.source + ":" + ar.currentline + " (" + (ar.name ? ar.name : "[top]") + ")"); + } else { + got_error = true; + } + } else { + got_error = true; + } + level++; + } while (!got_error); + push(msg); + lua_error(L); } -- cgit v1.2.3