[1.0.1] How to handle FindFailed exception

Asked by Googoo

1. Using Sikuli 1.0.0 sikuli-script.jar
     - Created a Java class that performs a Sikuli script and import org.sikuli.script.FindFailed
     - Wrapped your Sikuli script actions in a try-catch block and catch the missing exception as follows:
import org.sikuli.script.FindFailed;
import org.sikuli.script.Key;
import org.sikuli.script.Match;
import org.sikuli.script.Screen;
        Import
        try {
        Screen myScreen= new Screen();
        ...
        ...
        myScreen.type(Key.F1);
        ....
        }
  catch( FindFailed e ) {
     Assert.fail( "Error with Sikuli script: " + e.getMessage() );
     e.printStackTrace();
     throw new AssertionError( e.getMessage() );
  }

2. Upgraded to sikuli 1.0.1 sikuli-script.jar
     Getting compilation error - FindFailed is never thrown in body of try statement

   Please advise

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
Yu (yuri-litovchenko) said :
#1

Hello!

In Sikuli IDE I've got the following
[error] NameError ( global name 'FindFailed' is not defined )

after executing functions with try... except(FindFailed)
the issue had also appeared right after I've updated to new version. I didn't change a thing in my scripts too.

Revision history for this message
RaiMan (raimund-hocke) said :
#2

--- at comment #1:
I linked the bug

--- at your question:
a simple type without an image does not throw an exception.

Only functions that have an image to be searched before the action throw FindFailed exceptions.

Can you help with this problem?

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

To post a message you must log in.