summaryrefslogtreecommitdiff
path: root/Examples/lua/exception/runme.lua
diff options
context:
space:
mode:
authorMark Gossage <mark@gossage.cjb.net>2008-03-27 01:58:30 +0000
committerMark Gossage <mark@gossage.cjb.net>2008-03-27 01:58:30 +0000
commit11647d87e8f3fab24a0b265555ff17847ed04405 (patch)
treea316f7abe8d269afc4aa560f8dec0c4973d0fabf /Examples/lua/exception/runme.lua
parent97b910d7261c7019404fa53fefedebe6149726f9 (diff)
downloadswig-11647d87e8f3fab24a0b265555ff17847ed04405.tar.gz
[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
Diffstat (limited to 'Examples/lua/exception/runme.lua')
-rw-r--r--Examples/lua/exception/runme.lua33
1 files changed, 33 insertions, 0 deletions
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)