ERR

From OpenEUO
Revision as of 21:13, 1 November 2010 by Ximan (Talk | contribs) (Created page with "== Description == ERR is a unique library defined value that is employed in place of nil in certain areas. It's best to pull ERR into the global environment if needed to any...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Description

ERR is a unique library defined value that is employed in place of nil in certain areas. It's best to pull ERR into the global environment if needed to any degree. The type returned by type(ERR) is 'table', so it should be explicitly tested against if it is an expected return value. ERR only comes into play if inlined error redirection has been selected.

local sl = dofile(getinstalldir()..'/lib/simplelib.lua')
ERR = sl.ERR
sl.slredirect('i')         -- enable inline error handling
local td = sl.testdummy(1) -- library test object
local a,b = td.go(3)       -- raise a runtime error
print(tostring(a == ERR)..' '..b)

--> 'true 1'

See Also