Skip to content

Commit

Permalink
Helpful Remediation in Known Error Situation (#1115)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmarcaur authored Aug 14, 2024
1 parent 6e10da3 commit 58af349
Showing 1 changed file with 9 additions and 2 deletions.
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

0 comments on commit 58af349

Please sign in to comment.