I'm making use of SikuliX's API within my own personal library. The idea is to reference my library alone in external projects which incorporates the parts of SikuliX that I require.
Now, SikuliX throwns a FindFailed
exception, which I required. I tried to do:
public class FindFailed extends org.sikuli.script.FindFailed {
FindFailed(String msg) { super(msg); }
}
Which seemed to make sense. However, when attempting to use a throws
statement in one of the methods:
import org.mylibrary.exceptions.FindFailed;
public static boolean clickFinishButton() throws FindFailed {
pattern = PatternManager.loadPattern("my-image.png");
screen.wait(pattern, 10);
region = screen.exists(pattern);
region.click(pattern);
return true;
}
I still get an Unhandled exception type FindFailed
warning. Changing it back to the original org.sikuli.script.FindFailed
will of course work, however making use of try-catch
in an external project will require me to re-add the relevant SikuliX jar file.
What I would like to do, is simply wrap the FindFailed
exception that is being thrown by SikuliX and use it internally and externally with my library.
The primary goal of all of this is to wrap around another API with my own additional methods and such, so that when I reference this library, the later projects don't have to reference SikuliX's jar as well.
- - - - My Library - - - <—————— External Project
| |
| SikuliX |
- - - - - - - - - - - -
As is it right now, I require to do the following:
- - - - My Library - - - <—————— External Project
| | |
| SikuliX | |
- - - - - - - - - - - - v
SikuliX (Again)
So far I've changed things as follows which seems to work.
public class FindFailed extends Exception {
public FindFailed(Throwable cause) { super(cause); }
}
I now don't extend any third party Exceptions. And instead I proceed by doing the following:
public static boolean clickNewScan() throws FindFailed {
pattern = PatternManager.loadPattern("my-image.png");
region = screen.exists(pattern);
try {
screen.wait(pattern, 60);
region.click(pattern);
} catch (org.sikuli.script.FindFailed e) {
throw new FindFailed(e);
}
return true;
}