OScript API/Built-in Package Index |
An Error represents either a system-defined or user-defined Error. Errors can be used not only to indicate if an operation failed or was successful (in which case a Boolean would suffice), but also to indicate why a failure occurred. For example, if you attempt to copy a file to the desktop, the process can either succeed or fail. If it fails, it could be because the file to copy cannot be found, because the destination disk is full, because a file with that name already exists, and so on. A specific Error can be generated for each case, allowing the application designer to determine the reason the function failed. Errors provide OScript with error-handling more powerful than any found in the C language or Pascal, even though Errors are not as powerful as C++ and Java's Exceptions.
An Error can be thought of as containing two parts; the Integer error identifier and the String error message. Errors are referred to in scripts by their error identifiers, but the error message can be used to provide the user with information about the type of error that occurred.
There are two types of Errors used in OScript:
Once an Error type is defined, it exists for the remainder of the application execution. It is not disposed of when the script creating the Error completes execution.
Unlike most other OScript data types, the Error value is special the way Undefined (null) is in that any type of variable can assume an Error value. This allows a variable of any type and store a valid value in it if the operation was successful, or store an Error in it if the operation failed (note: this has the interesting effect that the Boolean type can actually be any of four values; True, False, Undefined, or Error).
Error return value indicating that the errorID parameter to method Error.Get() is neither a system ID nor a user-defined ID.
Ends script execution.
Defines a new Error value and its associated Error message.
Returns the String description associated with the specified Error.
Gets the corresponding Error value.
Returns an
Error return value indicating that the errorID parameter to Error.Get() is neither a system ID nor a user-defined ID.
Ends script execution. It does not return a value. It is used for debugging. If status is a value of type Error, the status that ends script execution is the Integer related to the Error from either system Errors or customized Error.Define() Errors. Otherwise, if status is not a value of type Error or is not specified, script execution is ended with the status Unknown Abort. The Scheduler built-in functions also provide a way to suspend or end script execution.
Specifies an optional value, either of type Error, or any other type. If not specified, then execution will be aborted with a status indicating an Error.Abort().
None-- execution of the current script terminates.
Defines a new Error value and its associated Error message. The Error remains defined for the duration of the program execution only. The newly defined Error value can be retrieved using Error.Get().
An Integer indicating a unique identifier for the Error which must be within the range of 1024 to 2047.
Specifies a String text description for the Error.
Returns a new value of type Error.
Returns the String description associated with the specified Error. The Echo built-in function can display the text of an Error in the Debug window, by passing the Error to the function.
Specifies the Error whose String is returned. This Error can be a system Error, or an Error created using Error.Define().
The String associated with the Error.
Gets the corresponding Error value.
An Integer Error status.
The Error corresponding to the specified status, if found; otherwise Error.E_NoSuchError.
Returns the Integer status value associated with the specified Error.
Passed a value of type Error that was created by Error.Define(), this returns the Integer status parameter defined for the Error.
Specifies an Error value for which the status is returned.
The ID number for the specified Error.
Copyright © 2022 OpenText Corporation. All rights reserved. |