Skip to content

Specify failure reason for JX Browser errors #7925

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

Merged
merged 3 commits into from
Feb 4, 2025
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
40 changes: 39 additions & 1 deletion flutter-idea/src/io/flutter/jxbrowser/EmbeddedJxBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,51 @@ public Logger logger() {
}
final Engine engine = engineRef.get();
if (engine == null) {
showMessageWithUrlLink("JX Browser engine failed to start", contentManager);
showMessageWithUrlLink(jxBrowserErrorMessage(), contentManager);
return null;
} else {
return new EmbeddedJxBrowserTab(engine);
}
}

private @NotNull String jxBrowserErrorMessage() {
final String defaultError = "JX Browser engine failed to start";
if (jxBrowserManager == null) {
return defaultError;
}
switch (jxBrowserManager.getStatus()) {
case NOT_INSTALLED:
return "JX Browser is not installed";
case INSTALLATION_IN_PROGRESS:
return "JX Browser installation in progress";
case INSTALLATION_SKIPPED:
return "JX Browser installation skipped";
case INSTALLATION_FAILED:
final InstallationFailedReason failedReason = jxBrowserManager.getLatestFailureReason();
final @Nullable String errorFromFailedMessage = jxBrowserErrorFromFailedReason(failedReason);
return errorFromFailedMessage != null ? errorFromFailedMessage : defaultError;
default:
return defaultError;
}
}

private @Nullable String jxBrowserErrorFromFailedReason(@Nullable InstallationFailedReason failedReason) {
if (failedReason == null) return null;
final FailureType failureType = failedReason.failureType;
if (failureType == null) return null;
return switch (failureType) {
case SYSTEM_INCOMPATIBLE -> "System is incompatible with JX Browser";
case FILE_DOWNLOAD_FAILED -> "JX Browser file download failed";
case MISSING_KEY -> "JX Browser license key is missing";
case DIRECTORY_CREATION_FAILED -> "JX Browser directory creation failed";
case MISSING_PLATFORM_FILES -> "JX Browser platform files are missing";
case CLASS_LOAD_FAILED -> "JX Browser class load failed";
case CLASS_NOT_FOUND -> "JX Browser class not found";
default -> null;
};

}

private void manageJxBrowserDownload(ContentManager contentManager) {
final JxBrowserStatus jxBrowserStatus = jxBrowserManager.getStatus();

Expand Down