if pcall(foo) then -- no errors while running `foo' ... else -- `foo' raised an error: take appropriate actions ... end