Throw an exception and handler

Hi All,

I've a script which execute 10 other scripts. Is there anyway that I could throw an exception and handler to capture an errors if any script failed so that it could continue to execute next scripts? If you could show me how or provide me sample code, I'm very appreciated.

Best Regards,

Comments

  • Hi All,

    I found it in the sensetalk guide. It is not much but it is good for start.

    Have a nice day,

    Best Regards,
  • JonathanOSXJonathanOSX ForumAdmin admin
    Exceptions in SenseTalk are easy and similar to other exception handling mechanisms. For complete details please read the Error Handling section of the SenseTalk Reference manual.

    To throw an exception you simply use the Throw command like this
    Throw "Something Went Wrong"
    
    This is also how Eggplant reports any unrecoverable errors like not finding an image to click on.

    If you want to handle an exception you put that segment of code in a try catch block like this
    try
    	MyScript
    catch
    	LogError "MyScript Failed"
    end catch
    (contine on)
    
    In the catch portion you can log an error (as show above) and the script will continue on but when it finishes the entire run will report as an error.
    You could also do a regular Log message or a LogWarning message.

    Of course if you want this behavior for each of the many scripts you are calling you might encapsulate that code into a simple little handler that takes a script name as a parameter. (Example Script Included)

    I should also call your attention to the built-in RunWithNewResults handler which takes a script name and causes that script to run so as to generate an independent log file, it will also capture and return the result (success or failure). For more details please see the RunWithNewResults section in the Eggplant Reference Manual.
Sign In or Register to comment.