User Tools

Site Tools


seterrors_save_the_error_state_.htm
Navigation:  ABC Library Reference > ErrorClass > ErrorClass Methods >====== SetErrors (save the error state) C6H0009.jpg ====== Previous pageReturn to chapter overviewNext page

SetErrors

blk2blue.jpg

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

seterrors_save_the_error_state_.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1