lua-users home
lua-l archive

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


The LuaSocket docs indicate that socket.protect can be used to
generate a safe function from another function that throws exceptions.
 The docs tell me I can protect any function that "is a function that
calls try (or assert, or error) to throw exceptions".  I'm missing
something because I can't get it to work with assert.  I'm using Lua
5.0.2.

This:
require'socket'
function f1()
    socket.try(1==2)
end
print(socket.protect(f1)())

prints, as expected:
nil    nil

But this:
require'socket'
function f1()
    assert(1==2)
end
print(socket.protect(f1)())

results in an "assertion failed" exception.

What have I missed here?

Thanks,
Bill