[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: pcall fails
- From: steve donovan <steve.j.donovan@...>
- Date: Tue, 20 Sep 2011 14:32:00 +0200
On Tue, Sep 20, 2011 at 2:22 PM, Thijs Schreijer
<thijs@thijsschreijer.nl> wrote:
> 133 local s = pcall(filters:add(123))
Ah, pcall() is passed a _function_, so you need to do this:
local ok, s = pcall(function() return filters:add(123) end)
Here ok will be true or false depending on whether the code threw an
error; s will then be the error, or the result of the function if
successful.
In your case, could also do
local ok, s = pcall(filters.add,filters,123)
since pcall() can take arguments.
steve d.