| **Navigation:**  [[abc library reference.htm|ABC Library Reference]] > ErrorClass > ErrorClass Methods >====== SetErrors (save the error state) {{c6h0009.jpg|C6H0009.jpg}} ====== | [[setdefaultcategory set default error category .htm|{{btn_prev_n.gif|Previous page}}]][[abc library reference.htm|{{btn_home_n.gif|Return to chapter overview}}]][[setfatality set severity level for a particular error .htm|{{btn_next_n.gif|Next page}}]] | | || **SetErrors** {{blk2blue.jpg|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 process specified error .htm|Throw]]