Skip to content

Commit

Permalink
fix: output version string when version parsing fails (#12530)
Browse files Browse the repository at this point in the history
This should ease debugging of problems like 
"UnknownVersionException: Unable to detect version of pnpm"
  • Loading branch information
Artur- authored Dec 10, 2021
1 parent 5ec8ddd commit 092578e
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -975,13 +975,23 @@ public CommandExecutionException(Throwable cause) {

protected static FrontendVersion getVersion(String tool,
List<String> versionCommand) throws UnknownVersionException {
String output;
try {
String output = executeCommand(versionCommand);
return new FrontendVersion(parseVersionString(output));
} catch (IOException | CommandExecutionException e) {
output = executeCommand(versionCommand);
} catch (CommandExecutionException e) {
throw new UnknownVersionException(tool,
"Using command " + String.join(" ", versionCommand), e);
}

try {
return new FrontendVersion(parseVersionString(output));
} catch (IOException e) {
throw new UnknownVersionException(tool,
"Expected a version number as output but got '" + output
+ "'" + " when using command "
+ String.join(" ", versionCommand),
e);
}
}

/**
Expand Down

0 comments on commit 092578e

Please sign in to comment.