lua-users home
lua-l archive

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


Here is a nice exaple by lhf:

http://lua-users.org/lists/lua-l/2002-12/msg00046.html

> Tom Spilman wrote:
> >   When lua returned the error is simply got the message
> >
> >   "attempt to call a string value"
>
> This error is not the syntax error from your script...
>
> >   luaL_loadbuffer( state, buffer, size, filename );
> >   lua_pcall( state, 0, LUA_MULTRET, 0 );
>
> What happens is that the luaL_loadbuffer call fails and leaves an error
> message on the stack.  Then lua_pcall tries to call a string value...
There
> you go!  So you should check the result code of the luaL_loadbuffer call
and
> report the error string if it failed.  See section 3.10 "Loading Lua
chunks"
> of the manual.  (luaL_loadbuffer is a simple lua_load wrapper.)
>