lua-users home
lua-l archive

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


Allocate userdata that are, contain or point to your exceptions, and give them a metatable that implements __tostring, would be my recommendation.


On Nov 17, 2011, at 3:12 PM, Mak Nazečić-Andrlon wrote:

> Hi there,
> I'm currently working on an awesome two-way C++-Lua binding (which I'm
> not going to link to yet, tee-hee). I'm trying to find a good way to
> map C++ exceptions to Lua errors. By definition, in C++, an exception
> is something  which should not go unnoticed, yet handleable. The best
> way to map it to Lua seems to be errors, but errors are customarily
> strings. The amount of information one can attach to a string is
> rather limited, but throwing more complete objects isn't really Lua-y.
> So, what *is* the purpose of the mechanism if it's primarily meant for
> throwing strings, and what would be the best way to Lua-fy C++
> exceptions?
> 
> Cheers,
> Mak Nazečić-Andrlon
>