Skip to content

Commit 3db7eb9

Browse files
committed
Handle EmptyNodeQueryExceptions in Finder
1 parent 65a97a6 commit 3db7eb9

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/main/java/javafxlibrary/utils/finder/Finder.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import javafxlibrary.utils.RobotLog;
2424
import javafxlibrary.utils.TestFxAdapter;
2525
import org.testfx.api.FxRobotInterface;
26+
import org.testfx.service.query.EmptyNodeQueryException;
2627

2728
import java.util.*;
2829

@@ -141,13 +142,21 @@ private Set<Node> findAll(Parent root, int queryIndex) {
141142

142143
private Node executeFind(Parent root, Query query) {
143144
RobotLog.debug("Executing find with root: " + root + " and query: " + query.getQuery());
144-
FindOperation findOperation = new FindOperation(root, query, false);
145-
return (Node) findOperation.executeLookup();
145+
try {
146+
FindOperation findOperation = new FindOperation(root, query, false);
147+
return (Node) findOperation.executeLookup();
148+
} catch (EmptyNodeQueryException e) {
149+
return null;
150+
}
146151
}
147152

148153
private Set<Node> executeFindAll(Parent root, Query query) {
149154
RobotLog.debug("Executing find all with root: " + root + " and query: " + query.getQuery());
150-
FindOperation findOperation = new FindOperation(root, query, true);
151-
return new LinkedHashSet<>((Set<Node>)findOperation.executeLookup());
155+
try {
156+
FindOperation findOperation = new FindOperation(root, query, true);
157+
return new LinkedHashSet<>((Set<Node>)findOperation.executeLookup());
158+
} catch (EmptyNodeQueryException e) {
159+
return Collections.emptySet();
160+
}
152161
}
153162
}

0 commit comments

Comments
 (0)