lua-users home
lua-l archive

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


On 25/06/2011 21.21, Rebel Neurofog wrote:
But that's not the assert () way.
I can't create assertable function like:

function ob.method ()
    return func (), get_error
end

and then call it using assert ()

Kinda no chaining...




Ok, that's true.

But you didn't mention this use case in your previous post.

Anyway isn't it sufficient to roll your own specialized "assert" to be used in your code?

-----------------------------------------------
local function new_assert( condition, err )
  if not condition then
      if type( err ) == 'function' then
         assert( false, err() )
      else
         assert( false, err )
      end
  end
end
-----------------------------------------------