PopulateError PowerScript function
Description
Fills in the Error object without causing a SystemError event.
Syntax
1 |
<span>PopulateError</span> ( <span>number</span>, <span>text </span>) |
Argument |
Description |
---|---|
number |
The integer to be stored in the number |
text |
The string to be stored in text property |
Return Values
Integer. Returns 1 if it succeeds and
-1 if an error occurs. The return value is usually not used.
Usage
If the values you want to populate the Error object with depend
on the current value of a variable in your script, you can use PopulateError to
assign values to the number and text fields in the Error object
(the remaining fields of the Error object will be populated automatically,
including the line number of the error). Then you can call SignalError without
arguments to trigger a SystemError. You will 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.
Examples
The gf_DoSomething function
takes a table name and a record and returns 0 for success and a
negative number for an error. The following statements set the number
and text values in the Error object according to a script variable,
then trigger a SystemError event once the processing is complete:
1 |
li_result = gf_DoSomething("Company", record_id) |
1 |
1 |
IF (li_result < 0) THEN |
1 |
   CHOOSE CASE li_result |
1 |
   CASE -1 |
1 |
   <span>   PopulateError</span>(1, "No company record exists & <br>      record id: " + record_id) |
1 |
   CASE -2 |
1 |
   <span>   PopulateError</span>(2, "That company record is & <br>      currently locked. Please try again later.") |
1 |
   CASE -3 |
1 |
   <span>   PopulateError</span>(3, "The company record could & <br>      not be updated.") |
1 |
   CASE else |
1 |
   <span>   PopulateError</span>(999, "Update failed.") |
1 |
   END CHOOSE |
1 |
   SignalError() |
1 |
END IF |