Navigation: ABC Library Reference > ErrorClass > ErrorClass Methods >====== SetErrors (save the error state) ====== | |
SetErrors
The SetErrors method saves the current error state for use by the ErrorClass.
Implementation:
The SetErrors method saves the return values from ERROR(), ERRORCODE(), FILEERROR(), and FILERERRORCODE(). The saved values are used for expansion of any %Error, %ErrorCode, %FileError, or %FileErrorCode macro symbols within the error message text.
The Throw method calls SetErrors prior to handling the specified error, therefore you only need to call the SetErrors method when you do not use the Throw method.
Example:
!an error occurs
GlobalErrors.SetErrors !save the error state
OPEN(LogFile) !open log (changes the error state)
Log:Text = FORMAT(TODAY(),@D1)&' '&FORMAT(CLOCK(),@T1)
ADD(LogFile) !write log (changes the error state)
RETURN GlobalErrors.TakeError(Msg:AddFailed)!process error with saved error state
See Also: Throw