From 11647d87e8f3fab24a0b265555ff17847ed04405 Mon Sep 17 00:00:00 2001 From: Mark Gossage Date: Thu, 27 Mar 2008 01:58:30 +0000 Subject: [lua] Added a typemap DISOWN for SWIGTYPE* and SWIGTYPE[], and support for %delobject feature. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10326 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/lua/exception/runme.lua | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'Examples/lua/exception/runme.lua') diff --git a/Examples/lua/exception/runme.lua b/Examples/lua/exception/runme.lua index 63299888e..39b2d6da8 100644 --- a/Examples/lua/exception/runme.lua +++ b/Examples/lua/exception/runme.lua @@ -61,3 +61,36 @@ for i=1,3 do end end end + +-- this is a bit crazy, but it shows obtaining of the stacktrace +function a() + b() +end +function b() + t:message() +end +print [[ +Now lets call function a() + which calls b() + which calls into C++ + which will throw an exception!]] +ok,res=pcall(a) +if ok then + print " that worked! Funny" +else + print(" call failed with error:",res) +end +print "Now lets do the same using xpcall(a,debug.traceback)" +ok,res=xpcall(a,debug.traceback) +if ok then + print " that worked! Funny" +else + print(" call failed with error:",res) +end +print "As you can see, the xpcall gives a nice stacktrace to work with" + + +ok,res=pcall(a) +print(ok,res) +ok,res=xpcall(a,debug.traceback) +print(ok,res) -- cgit v1.2.1