[attrname := ] FAIL [ ( errormessage | errorcode ) ] ;
[attrname := ] FAIL( errorcode , errormessage ) ;
[attrname := ] FAIL( datatype [, [ errorcode ] [, errormessage ] ] ) ;
attrname | Optional. The action name, which turns the action into an attribute definition, therefore not executed until the attrname is used as an action. |
errormessage | Optional. A string constant containing the message to display. |
errorcode | Optional. An integer constant containing the error number to display. |
datatype | The value type, name of a RECORD structure, DATASET, or DICTIONARY to emulate. |
The FAIL action immediately halts processing on the workunit and displays the errorcode and/or errormessage. The third form is available for use in contexts where a value type or dataset is required. FAIL may not be used in an expression context (such as within a TRANSFORM)--use the ERROR function for those situations.
Example:
IF(header.version <> doxie.header_version_new, FAIL('Mismatch -- header.version vs. doxie.header_version_new.')); FailedJob := FAIL('ouch, it broke'); sPeople := SORT(Person,Person.per_first_name); nUniques := COUNT(DEDUP(sPeople,Person.per_first_name AND Person.address)) : FAILURE(FailedJob); MyRecSet := IF(EXISTS(Person),Person, FAIL(Person,99,'Person does not exist!!'));