Encountering "Script Failed" error

Hi All,

I have written a function in one script which i'm calling in another function in the same suite. I'm calling the function using "Start using <script>" and "Stop using<script>"commands, but on running the script i'm encountering the "Script failed" error.

Below is the error on executing the script:
FAILURE AScreen_Error.tiff
SRUN_RecursionLimitedExceeded:
Handlers were called to a depth exceeding the maximum limit(13).

I tried executing the function when present in the same script as that of function call, and is working perfectly fine. The error is encountered only in the case of funtion and function call in different scripts.

Let me know why and when this error occurs and what is to be done to resolve the error.

Comments

  • Calling one function from another function in the same suite should work. However, SenseTalk is incapable of handling function/handler calls that exceed a depth of 13 at any given time.

    You will encounter the same error for recursive calls:
    put sum(13) -- within limit
    put sum(14) -- exceeds limit
    
    function sum num
    	if num is 1 then 
    		return 1
    	else
    		return sum (num - 1) + num
    	end if
    end sum
    
  • Hi,

    Could you please let us know when this error occurs.
    what does "exceed the depth of 13 " exactly means. What is to be done to resolve this error.
    Is it possible to reduce the depth value to less than 13.
  • This error WILL occur if you have a function/handler that calls another function/handler that calls another function/handler that calls another function/handler...13 times in a row.
    function1  -- calls function1: call depth of 1
    
    function function1
       function2   -- calls function2: call depth is now 2
    end function1
    

    The only way you can avoid this error is by not having too many nested function calls to other function/handlers.
  • This is really a bummer of a system limitation. Will this ever be fixed?

    ~Charles
  • JonathanOSXJonathanOSX ForumAdmin admin
    We agree and yes it is on the list to be fixed. If it were a simple bug we would have fixed it already but it does require some reworking to resolve.
  • So for anyone out there what would be the best way to figure out how deep the rabbit hole goes? Since I have up to 4 scripts being called to it can be hard to figure out where I am breaking Eggplant.

    Thanks,
    Charles
  • SenseTalkDougSenseTalkDoug ForumAdmin admin
    You may have to do a little exploring. The CallStack() function may come in handy for this. It returns a list of stack frames -- property lists that provide some information about what handler is active at each level. If you have a particular script or handler that is likely to be called at a fairly deep level, you can have it check the call depth when it is first called by looking at "the number of items in the callStack" -- if it's close to 13 it may be time to exit gracefully before everything comes tumbling down.

    The other approach you might take is to set a breakpoint in your script -- possibly a conditional one based on the call depth, like this:
    if the number of items in the callStack is more than nine then pauseScript
    
    When you hit your breakpoint, you can use the stack frame popup at the top of the Run window to interactively explore what's going on in your script. This approach allows you to check the current values of variables in each frame, etc. which may be helpful.
  • SRUN_RecursionLimitExceeded Handlers were called to a depth exceeding the maximum limit (40)

    my script failed on
    Disconnect

    I also named my script Disconnect.script. I found posts here to resolve this and all I had to do was to rename my script to "DisconnectCurrent" and that resolved my issue.

    I'm using a Mac OS X.
  • JonathanOSXJonathanOSX ForumAdmin admin
    As an update on this issue. The call depth limit has been extended to 40 levels which is usually enough for the majority of scenarios.

    As Kathryn encountered -- the most common time you hit this error is when you inadvertently call your own function recursively. Like having a disconnect script that calls disconnect. It's just calling itself over and over until you have hit the recursion limit.

    If you truly want to overwrite an Eggplant function then you need to pass the message to the back end within the overwritten command. Here is a trivial example, see the SenseTalk reference for more details:
    on click
      -- do special logging or whatever
      pass message and continue -- Have Eggplant do normal click behavior
    end on
    
Sign In or Register to comment.