SignalError PowerScript function
Description
Causes a SystemError event at the application level.
Syntax
1 |
<span>SignalError</span> ( { <span>number</span> }, { <span>text</span> } ) |
Argument |
Description |
---|---|
number (optional) |
The integer (stored in the number property |
text |
The string (stored in the text property |
Return Values
Integer. Returns 1 if it succeeds and
-1 if an error occurs. The return value is usually not used.
Usage
During development you can use SignalError to
test error-processing scripts.You can call PopulateError to
populate the Error object and call SignalError without
arguments. You can examine how the SystemError event script handles
the forced error. If you pass the optional number and text arguments
to SignalError, it populates all the fields in
the Error object and then triggers a SystemError event.
In an application, SignalError can also
be useful. For example, if a user error is so severe that you do
not want the application to continue, you can set values in the
Error object, including your own error number, and call SignalError.
You need to include code in the SystemError event script to recognize
and handle the error you have created.If there is no script for
the SystemError event, the SignalError function
does nothing.
For the runtime error numbers assigned to the Number property
of the Error object when an application error occurs, see the PowerBuilder
Users Guide.
Examples
These statements set values in the Error object and
then trigger a SystemError event so the error processing for these
values can be tested:
1 |
int error_number |
1 |
string error_text |
1 |
Error.Number = 1010 |
1 |
Error.Text = "Salary must be a positive number." |
1 |
Error.Windowmenu = "w_emp" |
1 |
1 |
error_number = Error.Number |
1 |
error_text = Error.Text |
1 |
1 |
<span>SignalError</span>(error_number, error_text) |