|
Script Object |
|
See Also: |
The Script.GetLastError() method retrieves the APGError object for the last error that occurred.
VBScript:
JScript:
| Script | The Script object. |
| oAPGError | An APGError object containing information about the last error that occurred in this script. |
If no error has occurred, GetLastError() still returns an APGError object, but all the properties are empty.
APGError objects record all errors. Many APGen reported errors that occur during script parsing and loading are non-fatal. Run-time errors are always fatal. If GetLastError() returns a non-empty APGError object, an error has occurred since the last time APGError.Clear() was called. When an APG script is run two or more times, errors from previous runs are not automatically cleared.
It is important to note that Script.GetLastError() should not be used for script error detection and error handling. This is because when a fatal error occurs, no more script code is run, so a Script.GetLastError() statement that occurs later in the script is useless for determining if an error has just occurred. However, Script.GetLastError() is useful for determining if the script failed the last time it was run, and it is useful for determining if any non fatal errors occurred when the script was parsed and loaded. Using APGScript.GetLastError() is useful for determining if an error occurred when the script was run.
Script language error handling should be used for error recovery at runtime. For more information on the different ways to handle errors, see Error Handling.