Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fallback to fxmlLoader on builder exception if present #4

Merged
merged 1 commit into from
May 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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);

Check warning on line 155 in fx2j-api/src/main/java/io/github/sheikah45/fx2j/api/Fx2jLoader.java

View check run for this annotation

Codecov / codecov/patch

fx2j-api/src/main/java/io/github/sheikah45/fx2j/api/Fx2jLoader.java#L149-L155

Added lines #L149 - L155 were not covered by tests
}
}
}

Expand Down