[1.0.1] Try/Catch for Error Handling in Sikuli?

Asked by Jennifer Coleman

I am trying to implement a try block that will run a workflow, but if some error pops up at any point during that workflow take a screenshot of the entire screen and exit the script gracefully...

I've tried the try/catch in multiple ways. Its only working for me if the error popup happens at the beginning of the workflow. If the error popup occurs at some midpoint in the workflow, Sikuli eventually fails with the FindFailed img error...

Here are two examples of code I've tried:

 try:
            wait(3)
            click("1374255931092.png")
            type("1374246828238.png", ip)
            type(username)
            type(pwd)
            click(ok)
            wait("1374589171654.png",60)
            click("1374602147221.png")

            click("1374602316521.png")

            while not exists("1374602366701.png"):
                click("1374247849159.png")

        except "ErrorScreenshot.png":
            takeScreenShot()

        print ip, username, pwd
        return 0

-------------------------------------------------------------------------------
 try:
            wait(3)
            click("1374255931092.png")
            type("1374246828238.png", ip)
            type(username)
            type(pwd)
            click(ok)
            wait("1374589171654.png",60)
            click("1374602147221.png")

            click("1374602316521.png")

            while not exists("1374602366701.png"):
                click("1374247849159.png")

        except FindFailed:
            takeScreenShot()

        print ip, username, pwd
        return 0

*** in the except FindFailed case I get a global name not defined error...

Any help is appreciated.

Thanks
Jennifer

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

look for a workaround/solution in the linked bug

Can you help with this problem?

Provide an answer of your own, or ask Jennifer Coleman for more information if necessary.

To post a message you must log in.