lua-users home
lua-l archive

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


Hello,

  To keep _ERRORMESSAGE working, I used a proxy function that grabs the 
_ERRORMESSAGE function and uses it as the errorhandler with lua_pcall:

int old_lua_call(lua_State* L, int nargs, int nresults)
{
  int result = 0;

  /* gets the error handler function and inserts it
     before the arguments */
  lua_getglobal(L, "_ERRORMESSAGE");
  lua_insert(L, 1);

  /* calls lua function, telling that the error handler is
     at position 1 of the stack */
  result = lua_pcall(L, nargs, nresults, 1);

  /* removes the error handler function */
  lua_remove(L, 1);
  
  /* returns the result (similar to lua_call) */
  return result;
}

Bye,

  Vinicius Almendra
  TeCGraf researcher

 
> Message: 7
> Date: Wed, 20 Aug 2003 17:05:22 -0300
> From: Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br>
> Subject: Re: _ERRORMESSAGE
> To: lua@bazar2.conectiva.com.br
> Message-ID: <200308202005.RAA23057@lua.tecgraf.puc-rio.br>
> 
> >Virgil Smith wrote:
> >> Will _ALERT work for your purposes?
> >
> >It would, if there was one in Lua 5.0. I found nothing about it in
> >the docs. If I am not mistaken there used to be an _ALERT in Lua 3.2...
> 
> _ALERT is present in Lua 5.0 for compatibility, but it's not part of the
> core,
> it's simply a protocol that lua.c uses.
> 
> The ony way to catch error messages is on the C side. Try lua_pcall and
> your
> own error function.
> --lhf
> 



__________________________________________________
Tecgraf/PUC-Rio Webmail