lua-users home
lua-l archive

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

I just noticed the wrap/unwrap pair in newtry/protect and fixed copas reimplementation of newtry/protect to do the same. I will release Copas 1.1.7 later, but you can grab the fixed code right now:

Fabio Mascarenhas

On Thu, Mar 25, 2010 at 6:32 PM, Diego Nehab <> wrote:

On Thu, Mar 25, 2010 at 1:56 PM, Jon Nalley <> wrote:
If I prevent socket.protect() from being overridden by copas the error
is returned as expected.  I am not sure if copcall() is making
assumptions about the exceptions that it may catch or if it is
actually encapsulating the error message in a table.  I am continuing

As I recall, socket.try() encapsulates the emsg in a table before
throwing it, and socket.protect() checks if the error is a table. If
it is, it assumes it was raised by try(), unwraps it, and returns
nil,emsg. Otherwise it just reraises it.

Could it be that copas's definition of socket.protect is not quite right?

The reason try() encapsulates the message is so protect()
can distinguish between normal error messages and the
messages generated by try(). Protect() will let the normal
error messages through. It is somewhat of a hack, but works
reasonably well until Lua starts raising error messages that
are not strings. :/