PopulateError

Description

Fills in the Error object without causing a SystemError event.

Syntax

PopulateError ( number, text )

Argument

Description

number

The integer to be stored in the number property of the Error object

text

The string to be stored in text property of the Error object

Returns

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

Example 1

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:

li_result = gf_DoSomething("Company", record_id)


IF (li_result < 0) THEN

   CHOOSE CASE li_result

   CASE -1 

      PopulateError(1, "No company record exists & 
      record id: " + record_id)

   CASE -2 

      PopulateError(2, "That company record is & 
      currently locked. Please try again later.")

   CASE -3 

      PopulateError(3, "The company record could & 
      not be updated.")

   CASE else 

      PopulateError(999, "Update failed.") 

   END CHOOSE 

   SignalError()

END IF

See also