[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Error handling
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Thu, 16 Feb 2006 21:34:17 -0200
> I'm thinking what would be nice is if error() (and the C versions like
> lua_error) could return more than just a text message.
This is already possible: you can use any Lua value as the "message".
In particular, you can send a complex error message by using a table.
Try this:
function f() error(print) end
print(print,pcall(f))
and this:
function f(x) error(x) end
function try(x) print(x,pcall(f,x)) end
try()
try(1)
try(nil)
try("bye")
try(try)
try{}
try(io.stdout)
--lhf