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

Helpful Remediation in Known Error Situation #1115

Merged
merged 1 commit into from
Aug 14, 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 @@ -139,13 +139,20 @@ private static Path getJdkPath(Project project) {
.map(Path::of)
.map(sdkHome -> sdkHome.resolve("bin").resolve("java" + (SystemInfo.isWindows ? ".exe" : "")))
.filter(Files::exists)
.orElseThrow(() -> new IllegalStateException("Could not determine jdk path for project " + project));
.orElseThrow(() ->
new IllegalStateException("Could not determine JDK path for project: " + project.getName()));
}

private static OptionalInt getSdkVersion(Project project) {
return getProjectJdk(project)
.map(FormatterProvider::parseSdkJavaVersion)
.orElseThrow(() -> new IllegalStateException("Could not determine jdk version for project " + project));
.orElseThrow(() ->
// This is not that common as our Gradle infrastructure should setup an SDK, but it does
// happen on occassion and it manifests as the plugin ceasing to format. Give a slight
// nudge for the manual remediation.
new IllegalStateException("Could not determine SDK version for project: " + project.getName()
+ ". Ensure you have an SDK set in "
+ "'Project Structure' -> 'Project Settings' -> 'Project' -> 'SDK'"));
}

private static OptionalInt parseSdkJavaVersion(Sdk sdk) {
Expand Down
Loading