How to log error at the beginning of the OnLogError handler
- 10 years ago
Well, the definition of the OnLogError Event http://support.smartbear.com/viewarticle/68044/ says
"The event occurs before an error message is posted to the test log."
so I don't think you can redefine that.
If you just want to make things easier to read in the log, try putting Append Log Folder at the top of the error handler function and Pop Log Folder at the bottom. This will indent the error handling and organize the log a little more.
See attached screenshots.
- 10 years ago
Hi Marin,
The possible (though not verified) implementation might be like this:
-- create a public flag that indicates if the code is in the error handler or not;
-- post an error from the eror handler;
-- continue wih the other stuff in the error handler.
I.e. something like this:
var boolIsInErrorhandler = false;
function GeneralEvents_OnLogError(Sender, LogParams) {
if (boolIsInErrorHandler) then
return;
boolIsInErrorHandler = true;
Log.Error(<initial error from LogParams>)
boolIsInErrorHandler = false;
Log.Message("handling error");
handlingError();
Log.Message("further handling error"); futherHandlingError(); Log.Message("initializing stuff");
initializingStuff();
//...and stop current test
Runner.Stop(true); }