Difference between revisions of "Using the Provided try() Exception Handler"

From OpenEUO
Jump to: navigation, search
m
(See Also)
 
(3 intermediate revisions by 2 users not shown)
Line 7: Line 7:
 
== See Also ==
 
== See Also ==
  
* [[error]]
+
* [http://www.easyuo.com/openeuo/wiki/index.php/Simplelib simplelib]
  
* [[pcall]]
+
* [http://www.easyuo.com/openeuo/wiki/index.php/Changing_Default_Error_Reporting_Mode error reporting and handling modes]
  
 
* [[clrerrors]]
 
* [[clrerrors]]
 +
 +
* [[error]]
  
 
* [[geterror]]
 
* [[geterror]]
 +
 +
* [[pcall]]
  
 
* [[slredirect]]
 
* [[slredirect]]
  
* [[try]]
+
* [[slverbosity]]
  
* [http://www.easyuo.com/openeuo/wiki/index.php/Changing_Default_Error_Reporting_Mode error reporting and handling modes]
+
* [[try]]

Latest revision as of 05:46, 3 November 2010

The try library method is provided as a integrated replacement for pcall which reports and redirects error handling in the same fashion as the library itself. Use try to wrap complex user functions wherever it is desirable to unify error reporting and or maintain script execution by silencing runtime errors that would otherwise halt the script.

To understand the available reporting and redirection modes, see the page on changing the default error reporting and handling mode. To set a specific mode, see slredirect. To understand what information is recorded with each detected error, see geterror. To clear all errors recorded internally and garbage collect, see clrerrors.

try should be used at an appropriately high level in user code such that handler functions don't clutter the source and aren't nested to any degree. try isn't intended to be used low level, either directly on library calls or as a method of program flow micromanagement. Save the error function for throwing bona fide exceptions to the current course of execution; don't use try as a sort of if then statement. If you need C style switch case or a deep elseif alternative, see the case library method.

See Also