-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Currently there is only a single latestError variable, which stores the last error code which was thrown. When a new event is thrown, this variable is overwritten by the new event code.
For writing tests, this is not favorable as one cannot state whether a fatal error was thrown in a longer section of code, when a lower level event was logged afterwards. Example pseudo-code:
call initErrorHandler(control="YES", errAction="REPORT", traceback="YES")
call routine_to_test(x = "invalid")
subroutine routine_to_test(x)
...
if (x == "invalid") then
call t%log_fatal("event 1") ! latestError = FATAL
end if
...
! The following line is always executed
call t%log_warning("event 2") ! latestError = WARNING
end subroutine routine_to_test()
The purpose of the exemplary test, is to check, whether "event 1" is correctly triggered (the test fails, if "event 1" was not triggered). With a single latestError variable, it is impossible to check, whether the fatal error was thrown as intended or not as it is always overwritten by "event 2".
This problem may be resolved by providing a latestError variable for each of the three error levels and associated mutator methods (set() and get()) to check their status independent of each other. Nevertheless, this would not resolve the identical issue if there were multiple consecutive fatal errors.
Another solution may be to implement a cumulative error counter for the three event levels.