Re: error exceptions

Jason McKesson <[email protected]> Tue, 09 Aug 2011 19:17:49 -0700
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <[email protected]>
On Tuesday, August 09, 2011 3:28:14 PM, Josh Stratton wrote:
> Thanks for the responses.  What is the corresponding luabind call
> similar to luaL_dostring that actually throws exceptions?
> 
> On Tue, Aug 9, 2011 at 3:22 PM, Nigel Atkinson<[email protected]>  wrote:
>> On Wed, August 10, 2011 12:43 am, Willi Schinmeyer wrote:
>>
>>> Am Dienstag, den 09.08.2011, 07:17 -0700 schrieb Josh Stratton:
>>>> so I'm assuming there is some error in there
>>>> I thought should raise an exception.
>>>
>>> Nope, errors don't usually raise exceptions, they just change the return
>>> value. Read the manual regarding luaL_dostring(), I don't know how to
>>> check its success off the top of my head.
>>
>>
>>
>>
>> luaL_dostring reurns 1 on error, and in that case you should find a string
>> describing the problem at the top of the Lua stack.
>>
>> Nigel
>>
>> ------------------------------------------------------------------------------
>> uberSVN's rich system and user administration ca
pabilities and model
>> configuration take the hassle out of deploying and managing Subversion and
>> the tools developers use with it. Learn more about uberSVN and get a free
>> download at:  http://p.sf.net/sfu/wandisco-dev2dev
>>
>> _______________________________________________
>> luabind-user mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/luabind-user
>>
>>
> 
> ------------------------------------------------------------------------------
> uberSVN's rich system and user administration capabilities and model
> configuration take the hassle out of deploying and managing Subversion and
> the tools developers use with it. Learn more about uberSVN and get a free
> download at:  http://p.sf.net/sfu/wandisco-dev2dev
> _______________________________________________
> luabind-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/luabind-user

There is no single Luabind call tha
t does what luaL_dostring does. You 
have to do all of the individual steps.

You have Lua compile the string into a chunk, using the standard Lua 
API (no exceptions). Then, if it compiled successfully, you have to use 
luabind::from_stack to convert the Lua chunk into a luabind::object 
(note that it will still also be on the stack, so you'll have to deal 
with that). Once it's a luabind::object, you can call it with 
operator().

------------------------------------------------------------------------------
uberSVN's rich system and user administration capabilities and model 
configuration take the hassle out of deploying and managing Subversion and 
the tools developers use with it. Learn more about uberSVN and get a free 
download at:  http://p.sf.net/sfu/wandisco-dev2dev