(CVAL('LAST ERROR'))
Returns the last error encountered.
This is an alternative to the SET ERROR VARIABLE method of -ERROR- trapping.
When using (CVAL('LAST ERROR')) the variable used to capture the error must be explicitly cleared, as opposed to SET ERROR VARIABLE, which is automatically cleared after each command, requiring error trapping logic immediately after each command. Furthermore, the SET ERROR VARIABLE method does not allow error trapping in nested code segments or large blocks of code.