lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Am 21.12.2012 um 14:42 schrieb Roberto Ierusalimschy:

>>> Or better yet, call lua_error in the first place (instead of throwing
>>> a C++ exception). In Lua, you can catch such errors with 'pcall'.
>> 
>> 
>> Can I catch this error on the Lua script? [...]
> 
>>> ................. In Lua, you can catch such errors with 'pcall'.
>                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Sorry, I have confused with lua_pcall (the C fuction). So I just
run a lua function with

if pcall(myfunc()) then
   no error
else
   error
end

A try-catch around a block does not work, so I must call each "function"
with pcall, do I ?

Thanks

Phil