Difference between revisions of "ERR"

From OpenEUO
Jump to: navigation, search
m (Description)
m (See Also)
Line 15: Line 15:
  
 
== See Also ==  
 
== See Also ==  
 +
 +
* [http://www.easyuo.com/openeuo/wiki/index.php/Simplelib simplelib]
  
 
* [[nil]]
 
* [[nil]]
 
* [[null]]
 
  
 
* [[non]]
 
* [[non]]
 +
 +
* [[null]]
  
 
* [[slredirect]]
 
* [[slredirect]]

Revision as of 09:29, 2 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. Inlined errors can alternatively be returned as (nil,eref) pairs, see slredirect for more information.

See Also