[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: assert with formatting
- From: Daurnimator <quae@...>
- Date: Fri, 13 Jul 2018 10:32:29 +1000
On 13 July 2018 at 10:11, <firstname.lastname@example.org> wrote:
> Quoting Luiz Henrique de Figueiredo <email@example.com>:
>> For that, you'll have to redefine assert to call error with the
>> correct stack level.
> Thank you, that's something I can work with. I looked at the source code and
> seems dirty to patch it into luaB_assert()
Writing your own assert function is quite easy:
function assert(cond, ...)
if cond then
return cond, ...
local err = select("#", ...) == 0 and "assertion failed!" or ...
The second parameter to 'error' tells it to ignore the 'assert'
function when generating a stack trace.