Skip to content

Commit

Permalink
Fallback to fxmlLoader on builder failure (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheikah45 authored May 12, 2024
1 parent 886c636 commit 44a1d28
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
@SuppressWarnings({"unchecked", "unused"})
public class Fx2jLoader {

private static final System.Logger LOGGER = System.getLogger(Fx2jLoader.class.getCanonicalName());

private static final List<Fx2jBuilderFinder> BUILDER_FINDERS;
private static final boolean FALL_BACK_TO_FXML;

Expand Down Expand Up @@ -143,10 +145,15 @@ public <T> T load() throws IOException {
Fx2jBuilder<? super Object, ? super Object> builder = (Fx2jBuilder<? super Object, ? super Object>) finder.findBuilder(
location);
if (builder != null) {
builder.build(controller, root, resources, controllerFactory);
setController(builder.getController());
setRoot(builder.getRoot());
return (T) builder.getRoot();
try {
builder.build(controller, root, resources, controllerFactory);
setController(builder.getController());
setRoot(builder.getRoot());
return (T) builder.getRoot();
} catch (Exception exception) {
LOGGER.log(System.Logger.Level.WARNING,
() -> "%s failed during build falling back".formatted(builder.getClass()), exception);
}
}
}

Expand Down

0 comments on commit 44a1d28

Please sign in to comment.