cancel
Showing results for 
Search instead for 
Did you mean: 

A recursive call to an event_handler has been detected

SOLVED
New Contributor

A recursive call to an event_handler has been detected

Hi,

i have created an event that reacts to a timeout error. Unfortunately it always comes to the message from the title. I can't find out what the reason could be? I call nothing recusively. I only want to click on Ok and then on ESC in case of an error message. But the event does not do this. Where is my mistake? Am I missing something?
Many thanks in advance,
Christoph

1 ACCEPTED SOLUTION

Accepted Solutions
Community Hero

Re: A recursive call to an event_handler has been detected

Hi,

 

As the message says, event handling procedure appears to be called recursively.

To provide you with more detailed answer, more details from you would be great: what type of event, code, screenshot of the tested application at the moment of error, etc.

 

Possible scenario as an example:

-- for the OnLogError event handler;

-- if the error occurs within the event handler's code (e.g. if the code attempts to click something and the click fails);

-- then the OnLogError will be triggered again, which will cause another attempt to click, which will fail and result in recursive call.

 

To handle the above scenario:

-- Either ensure that no error can happen in the event handler's code; or

-- Introduce a flag that will indicate whether or not event handling is active. Set the flag when entering event handler and clear it when leaving. Event handler's code must exit (with possible message to test log) if recursive call is detected.

Sample pseudocode:

var bOnErrorFlag = false; // flag that preserves its value between calls to OnLogErrorHandler() function

 

function OnLogErrorHandler(...)

{

  if (bOnErrorFlag)

  {

    Log.Warning('Recursive call to OnLogError. Event handler exited'); // Log.Error() must not be used!

    exit;

  }

  bOnErrorFlag = true;

  ...

  bOnErrorFlag = false;

}

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

1 REPLY 1
Community Hero

Re: A recursive call to an event_handler has been detected

Hi,

 

As the message says, event handling procedure appears to be called recursively.

To provide you with more detailed answer, more details from you would be great: what type of event, code, screenshot of the tested application at the moment of error, etc.

 

Possible scenario as an example:

-- for the OnLogError event handler;

-- if the error occurs within the event handler's code (e.g. if the code attempts to click something and the click fails);

-- then the OnLogError will be triggered again, which will cause another attempt to click, which will fail and result in recursive call.

 

To handle the above scenario:

-- Either ensure that no error can happen in the event handler's code; or

-- Introduce a flag that will indicate whether or not event handling is active. Set the flag when entering event handler and clear it when leaving. Event handler's code must exit (with possible message to test log) if recursive call is detected.

Sample pseudocode:

var bOnErrorFlag = false; // flag that preserves its value between calls to OnLogErrorHandler() function

 

function OnLogErrorHandler(...)

{

  if (bOnErrorFlag)

  {

    Log.Warning('Recursive call to OnLogError. Event handler exited'); // Log.Error() must not be used!

    exit;

  }

  bOnErrorFlag = true;

  ...

  bOnErrorFlag = false;

}

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors