Difference between revisions of "ERR"

From OpenEUO
Jump to: navigation, search
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
 
(4 intermediate revisions by the same user not shown)
Line 10: Line 10:
 
  print(tostring(a == ERR)..' '..b)
 
  print(tostring(a == ERR)..' '..b)
 
   
 
   
  --> '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.  Inlined errors can alternatively be returned as ([[nil]],eref) pairs, see [[slredirect]] for more information.
  
 
== See Also ==  
 
== See Also ==  
  
* [[nil]]
+
* [http://www.easyuo.com/openeuo/wiki/index.php/Simplelib simplelib]
  
* [[null]]
+
* [[EOF]]
 +
 
 +
* [[nil]]
  
 
* [[non]]
 
* [[non]]
 +
 +
* [[null]]
  
 
* [[slredirect]]
 
* [[slredirect]]

Latest revision as of 10:18, 24 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