Changes

Jump to navigation Jump to search

platform.registerErrorHandler

176 bytes added, 19:34, 24 June 2012
no edit summary
Line 2: Line 2:       −
This function sets the error handler callback function for the script. Setting an error handler callback function provides control over what happens when an error is encountered in the script. Returning a true value quietly kills the script and prevents any error reporting to the gui.  
+
This function sets the error handler callback function for the script. Setting an error handler callback function provides control over what happens when an error is encountered in the script.  
 +
Returning a true value lets the script continue, ignoring the error (no error screen).  
 
<br />
 
<br />
 
  
 
  
Line 22: Line 23:     
== Example  ==
 
== Example  ==
<syntaxhighlight>platform.registerErrorHandler(function(lineNumber, errorMessage, callStack, locals) ... end)</syntaxhighlight>
+
<syntaxhighlight>errorHandler = {}
 +
 
 +
function myErrorHandler(line, errMsg, callStack, locals)
 +
    print("Error handled ! ", errMsg)
 +
    table.insert(errorHandler, {line, errMsg, callStack, locals})
 +
    return true -- let the script continue
 +
end
 +
 
 +
platform.registerErrorHandler(myErrorHandler)</syntaxhighlight>
    
<br />
 
<br />
    
[[Category:platform]]
 
[[Category:platform]]

Navigation menu