[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: SWIG, C++ Exceptions, and Lua
- From: Miles Bader <miles@...>
- Date: Thu, 06 Mar 2008 09:55:23 +0900
Joey Mukherjee <firstname.lastname@example.org> writes:
> Is it possible to make SWIG and Lua work well with C++ exceptions? If
> so, what is the best way?
> Really, the only thing I need is for Lua to not swallow my exceptions
> and allow the exception to pass through to main program.
Hmm maybe I mis-understand the problem, but everything seems to work ok
swig just throws a normal lua error for its errors, and in my program,
my "top-level" calls into Lua use a function like this:
do_call (lua_State *L, int nargs, int nres)
int err = lua_pcall (L, nargs, nres, 0);
string err_str = lua_tostring (L, -1);
throw file_error (err_str);
So any error swig signals will cause that pcall to return an error, and
the above function will turn that into a C++ exception...
Religion, n. A daughter of Hope and Fear, explaining to Ignorance the nature
of the Unknowable.