lua-users home
lua-l archive

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


  I guess one aproach is to use a try {} catch block, as you mentioned. If you
really plan to use lots of exception handling in C++, then do everything with
exceptions, and only in the Lua "borders" you convert from one to the other.
So, you could use:

void dofile (char *filename) {
  if (lua_dofile(filename) != 0)
    raise exception;  // I don't remember the C++ syntax...
}

etc for dostring, lua_call, ...

  Any C++ function called from Lua should catch all exceptions, and then call
lua_error in the handler. In this way, everytime you come from Lua to C++
errors are turned into exceptions, and when going from C++ to Lua exceptions
become errors. In your particular example, you should not use a flag (iserror),
but an exception, since that is C++.

-- Roberto