Skip to content

Commit

Permalink
Improve vendor dep error handling for malformed files
Browse files Browse the repository at this point in the history
Does not parse hidden files. Fixes wpilibsuite/GradleRIO#726
Identifies file that failed to load or parse
  • Loading branch information
sciencewhiz committed Nov 18, 2024
1 parent d7a64d6 commit dddb72d
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void setHwSimulation(boolean value) {
public static List<File> vendorFiles(File directory) {
if (directory.exists()) {
return List.of(directory.listFiles(pathname -> {
return pathname.getName().endsWith(".json");
return pathname.getName().endsWith(".json") && !pathname.isHidden();
}));
} else {
return List.of();
Expand Down Expand Up @@ -169,7 +169,7 @@ public void loadFrom(File directory) {
try {
load(dep);
} catch(Exception e) {
throw new BuildException("Failed to load dependency", e);
throw new BuildException("Failed to load vendor dependency: " + f.getName(), e);
}
}
}
Expand All @@ -182,8 +182,8 @@ public void loadFrom(Project project) {
private JsonDependency parse(File f) {
try (BufferedReader reader = Files.newBufferedReader(f.toPath())) {
return gson.fromJson(reader, JsonDependency.class);
} catch (IOException e) {
throw new RuntimeException(e);
} catch (Exception e) {
throw new RuntimeException("Failed to parse vendor dependency: " + f.getName(), e);
}
}

Expand Down

0 comments on commit dddb72d

Please sign in to comment.