[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: std::exception Interoperability
- From: "Greg Falcon" <veloso@...>
- Date: Fri, 24 Mar 2006 17:56:04 -0500
Any time I see a catch(...), I start worrying, so I'd love to get a
look at your improvements to the exception handling.
On 3/24/06, Erik Cassel <email@example.com> wrote:
> I have patched Lua 5.1 to seamlessly work with std::exception.
> This lets me throw an std::exception-derived object from anywhere in C++
> code. Lua will catch it and translate it appropriately in
> Also, Lua uses an std::exception-derived class to throw Lua errors. This
> means I can catch errors thrown by Lua (as in lua_touserdata).
> The benefits of this approach are:
> 1) I don't have to write exception handlers in every entry point in my
> code. If my code is based on std/boost then I can be confident that
> exceptions thrown by my code will be handled by Lua. I don't have to
> translate them into lua_error() calls.
> 2) It is perfectly safe for me to intercept an exception thrown by Lua.
> Since Lua now throws std::exception-derived objects I can catch and inspect
> errors with a catch(std::exception&) clause. Moreover, if I decide *not* to
> re-throw the exception, then Lua automatically pops the error message from
> the stack.
> Has anybody else done something like this? Would it be useful to anybody?
> Have I missed something?
> I'd be happy to post my patch (and go over implementation details) and/or
> show some sample code of how it can be used.