Difference between revisions of "platform.registerErrorHandler"
Jump to navigation
Jump to search
(Created page with "platform.'''registerErrorHandler''' is a function that is part of the platform. This function sets the error handler callback function for the script. Se...") |
|||
(2 intermediate revisions by the same user not shown) | |||
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 | + | 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> | + | <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]] |
Latest revision as of 18:34, 24 June 2012
platform.registerErrorHandler is a function that is part of the platform.
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).
The error handler callback function will not be called for errors that occur during initialization or within on.restore.
This has been introduced in TI-Nspire OS 3.2 (Changes).
Syntax
platform.registerErrorHandler(function(lineNumber, errorMessage, callStack, locals) ... end)
Parameter | Type | Description |
---|---|---|
function | error handler callback function |
Example
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)