[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: error reporting question
- From: Mike Pall <mikelu-0509@...>
- Date: Fri, 16 Sep 2005 17:47:09 +0200
Hi,
Robert Raschke wrote:
> function foo()
> assert(nil, "an error")
> end
>
> dofile("conf")
>
> And the file conf just says "foo{}", then I'd like to get an error
>
> .../conf:1: an error
>
> instead of
>
> .../main.lua:3: an error
See the section in the manual about the error() function.
> Is there an easy way to do this?
function assert3(ok, ...)
if not ok then
error(..., 3)
end
return ok, ...
end
Requires Lua 5.1 due to the '...' syntax (but can be implemented
without it, too).
Bye,
Mike