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

When loading of FXML file fails, in some cases the error is not shown to the user #403

Merged
merged 19 commits into from
Jan 12, 2022

Conversation

Oliver-Loeffler
Copy link
Collaborator

@Oliver-Loeffler Oliver-Loeffler commented Aug 29, 2021

When loading of FXML file fails, in some cases the error is not shown to the user.
This is actually the case for #253.

The error detection in SceneBuilderApp only worked for cases of IOExceptions.
This case is caused by a NullPointerException coming from FXMLLoader inside FXOMLoader.

I cannot solve the issue #253 now but consider this behavior, that no error dialog is presented, as a bug.

Issue

Fixes #402
Related #327
Related #253
Related #54
(there are more very similar issues)

Progress

@abhinayagarwal abhinayagarwal added the bug Something isn't working label Aug 31, 2021
@abhinayagarwal abhinayagarwal added this to the 18 milestone Sep 1, 2021
String message = t.getMessage();
assertTrue(message.startsWith("javafx.fxml.LoadException:"));
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a few more test cases to assert both known and unknown causes when loading a FXML? May be also assert a case where XMLStreamException is thrown.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, of course. This is a good point.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Oliver-Loeffler,

Are you going to add some more test cases to move this PR forward?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there will be an update with more tests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @abhinayagarwal
There is a significant overlap with PR #405 hence I am waiting for your feedback regarding #405 before continuing here. When #405 becomes accepted, I'll rebase towards 405 and continue from there.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also now a case for a SAXParseException which is wrapped as cause in a IOException. This is the case when it is attempted to load and incomplete or broken XML structure.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abhinayagarwal Eventually it worked and now I have a case where the XMLStreamException is provoked and handled.

@Oliver-Loeffler
Copy link
Collaborator Author

@AlmasB If you like we can start with this one. Would be glad if you'd have an eye on this one. We have many older (some newer) issues related to FXML/FXOM loading. This PR is reviewed by @abhinayagarwal . Goal here is at first, that Scene Builder no longer silently ignores exceptions. There is actually a mechanism which displays the Exception contents to the user but this was not triggered in past. So users complained about FXMLs which failed to load.

Copy link
Collaborator

@AlmasB AlmasB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, please can you check the two questions.

@@ -668,7 +668,7 @@ private void performOpenFiles(List<File> fxmlFiles,
hostWindow.loadFromFile(fxmlFile);
hostWindow.openWindow();
}
} catch (IOException xx) {
} catch (RuntimeException | IOException xx) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason not to use Exception superclass here, i.e. why Runtime and IO only?

Copy link
Collaborator Author

@Oliver-Loeffler Oliver-Loeffler Jan 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good point, yes, you are absolutely right. This a leftover from searching what was happening. Catching any kind of exception is a better solution here. The map where exceptions are collected in is already suitable for all types of exceptions.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you wish to update this, happy to wait. Otherwise, it looks good to go.

}

private void handleUnknownAndMissingCauses(Exception x) throws IOException {
throw new IOException(x);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume throwing this is fine as it will be caught by the SB general exception handler?

Copy link
Collaborator Author

@Oliver-Loeffler Oliver-Loeffler Jan 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is handled in a proper way. The issue is shown to the user and a dump of the FXML file into a temp dir is performed. There is a proper exception handling downstream.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@AlmasB AlmasB merged commit cc20ec7 into gluonhq:master Jan 12, 2022
Copy link
Collaborator Author

@Oliver-Loeffler Oliver-Loeffler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

For some cases on errors during FXML Loading no error dialog is presented
3 participants