lua-users home
lua-l archive

Re: How to make sure some operations in ANY situation? (aka: with statement in Python)

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


2011年6月20日 Xavier Wang <weasley.wx@gmail.com>:
> But I have some things to do even if I want throw the error, I want to
> execute some code when the function I called have error, even if I don't
> care what error it does , I just want some resource to be clean .
Ah, like this?
local ok, err = pcall(problem_function)
if not ok then
 pcall(cleanup)
 error(err)
end
That is, re-raise the error.
steve d.

AltStyle によって変換されたページ (->オリジナル) /