Skip to content

Commit

Permalink
Improve error messages in ProtocResolver.java
Browse files Browse the repository at this point in the history
  • Loading branch information
ascopes authored Jul 28, 2024
1 parent d42836a commit 7b2fb32
Showing 1 changed file with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,17 @@ public Optional<Path> resolve(String version) throws ResolutionException {
: resolveFromMavenRepositories(version);

if (path.isPresent()) {
var resolvedPath = path.get();

try {
FileUtils.makeExecutable(path.get());
FileUtils.makeExecutable(resolvedPath);

} catch (IOException ex) {
throw new ResolutionException("Failed to set executable bit on protoc binary", ex);
throw new ResolutionException(

Check warning on line 95 in protobuf-maven-plugin/src/main/java/io/github/ascopes/protobufmavenplugin/protoc/ProtocResolver.java

View check run for this annotation

Codecov / codecov/patch

protobuf-maven-plugin/src/main/java/io/github/ascopes/protobufmavenplugin/protoc/ProtocResolver.java#L95

Added line #L95 was not covered by tests
"Failed to set executable bit on protoc binary at " + resolvedPath
+ ": " + ex.getMessage(),

Check warning on line 97 in protobuf-maven-plugin/src/main/java/io/github/ascopes/protobufmavenplugin/protoc/ProtocResolver.java

View check run for this annotation

Codecov / codecov/patch

protobuf-maven-plugin/src/main/java/io/github/ascopes/protobufmavenplugin/protoc/ProtocResolver.java#L97

Added line #L97 was not covered by tests
ex
);
}
}

Expand All @@ -99,8 +106,12 @@ public Optional<Path> resolve(String version) throws ResolutionException {
private Optional<Path> resolveFromUrl(String url) throws ResolutionException {
try {
return urlResourceFetcher.fetchFileFromUrl(new URL(url), ".exe");

} catch (IOException ex) {
throw new ResolutionException(ex.getMessage(), ex);
throw new ResolutionException(
"Failed to fetch resource from URL " + url + ": " + ex.getMessage(),

Check warning on line 112 in protobuf-maven-plugin/src/main/java/io/github/ascopes/protobufmavenplugin/protoc/ProtocResolver.java

View check run for this annotation

Codecov / codecov/patch

protobuf-maven-plugin/src/main/java/io/github/ascopes/protobufmavenplugin/protoc/ProtocResolver.java#L111-L112

Added lines #L111 - L112 were not covered by tests
ex
);
}
}

Expand All @@ -109,9 +120,10 @@ private Optional<Path> resolveFromMavenRepositories(String version) throws Resol
log.warn(
"It looks like you are using Android! Android is known to be missing "
+ "system calls for Linux that the official protoc binaries rely on "
+ "to work. If you encounter issues, run Maven again with the "
+ "-Dprotobuf.compiler.version=PATH flag to rerun with the version "
+ "of protoc that is on your $PATH."
+ "to work correctly. If you encounter issues, run Maven again with the "
+ "-Dprotobuf.compiler.version=PATH flag to rerun with a custom "
+ "user-provided version of protoc. If nothing fails, then you can "
+ "safely ignore this message!"
);
}

Expand Down

0 comments on commit 7b2fb32

Please sign in to comment.