-
Notifications
You must be signed in to change notification settings - Fork 221
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
Conversation
…s during FXML loading.
…oad() method in case of unknown cause.
42f17b1
to
f6d2a68
Compare
kit/src/test/resources/com/oracle/javafx/scenebuilder/kit/fxom/BrokenByUserData.fxml
Outdated
Show resolved
Hide resolved
String message = t.getMessage(); | ||
assertTrue(message.startsWith("javafx.fxml.LoadException:")); | ||
} | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
c698ac9
to
656f1f5
Compare
@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. |
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review completed.
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 ofIOExceptions
.This case is caused by a
NullPointerException
coming fromFXMLLoader
insideFXOMLoader
.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