error/exception hadling in luabind
"Domino" <[email protected]>
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <000c01c99f11$329f7060$97de5120$@fm> |
Hello,
My question is how to handle errors that tells something more than "lua
runtime error". In my code I need multiple scripts for the single lua state
that shouldn't know about each other so I'm using lua code to load the
scripts (the code comes from this list by the way). Below is the example of
the code that I have problem with:
// C++
std::string scriptLoaderCode("function scriptloader (scriptTable,
scriptname)\n \
local mt = {__index=_G} \
setmetatable(scriptTable, mt) \
local chunk = loadfile(scriptname) \
setfenv(chunk, scriptTable) \
chunk() \
end");
luaL_dostring(pLua, scriptLoaderCode.c_str());
{
luabind::object newtable = luabind::newtable(pLua);
try
{
luabind::call_function<void>(pLua, "scriptloader", newtable,
"test3.lua");
}
catch (luabind::error e)
{
std::cout << "exception:" << std::endl;
std::cout << "\t" << e.what() << std::endl;
}
}
And the lua code (just a simple test from documentation):
// lua
class 'lua_testclass'
function lua_testclass:__init(name)
self.name = name
end
function lua_testclass:print()
print(self.name)
end
class 'derived' (lua_testclass)
function derived:__init() super('derived name')
end
function derived:print()
print('Derived:print() -> ')
lua_testclass.print(self)
end
a = derived()
a:print()
This gave me an error "lua runtime error" so basically I still have no idea
what is wrong with the code. My guess it that it might be caused by the fact
that I load scripts via luacode but still if there is a compilation problem
it should give me some hint.
Thanks
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
luabind-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/luabind-user