Difference between revisions of "ERR"
From OpenEUO
m (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...") |
m (→Description) |
||
Line 11: | Line 11: | ||
--> 'true 1' | --> 'true 1' | ||
+ | |||
+ | If the 'i' flag has been set via [[slredirect]], then detected errors are inlined as an (ERR,eref) [[tuple]], where eref is a number that can be passed to [[geterror]] to return the recorded error table. | ||
== See Also == | == See Also == |
Revision as of 21:16, 1 November 2010
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'
If the 'i' flag has been set via slredirect, then detected errors are inlined as an (ERR,eref) tuple, where eref is a number that can be passed to geterror to return the recorded error table.