lua-users home
lua-l archive

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


> The lua_catch/throw functions would allow programmers to invent
> new error codes.  But IMHO they shouldn't do that.  The more
> error conditions you have the more trouble you get handling the
> errors in the catch-code.  Especially when used in extension
> libraries or packages.  You may be catching errors never seen
> before and unable to tell what to do with them...

If Lua had proper exceptions, which are very useful, then this is exactly
what Lua programmers would do, and rightly so. The point of exceptions is
that you only catch those that you *do* know what to do with; the others you
just pass through. Whether you do this as part of the syntax:

try do ... end catch (exception1, exception2) do ... end

where the arguments to catch specify which exceptions are caught, and the
rest are simply thrown on, or make the programmer do it:

try do ... end catch do if exc != myexc then throw(exc) else ... end end

the result is the same: you catch the exceptions you can handle, and
re-throw the rest. (Forgive the rather ugly pseduo-Lua eyntax I've
invented.)

-- 
http://sc3d.org/rrt/ | free, a.  already paid for (Peyton Jones)