Skip to content

Commit 7730d28

Browse files
authored
Improve vendor dep error handling for malformed files (#229)
Does not parse hidden files. Fixes wpilibsuite/GradleRIO#726 Identifies file that failed to load or parse
1 parent 917fa0d commit 7730d28

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/main/java/edu/wpi/first/nativeutils/vendordeps/WPIVendorDepsExtension.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public void setHwSimulation(boolean value) {
121121
public static List<File> vendorFiles(File directory) {
122122
if (directory.exists()) {
123123
return List.of(directory.listFiles(pathname -> {
124-
return pathname.getName().endsWith(".json");
124+
return pathname.getName().endsWith(".json") && !pathname.isHidden();
125125
}));
126126
} else {
127127
return List.of();
@@ -169,7 +169,7 @@ public void loadFrom(File directory) {
169169
try {
170170
load(dep);
171171
} catch(Exception e) {
172-
throw new BuildException("Failed to load dependency", e);
172+
throw new BuildException("Failed to load vendor dependency: " + f.getName(), e);
173173
}
174174
}
175175
}
@@ -182,8 +182,8 @@ public void loadFrom(Project project) {
182182
private JsonDependency parse(File f) {
183183
try (BufferedReader reader = Files.newBufferedReader(f.toPath())) {
184184
return gson.fromJson(reader, JsonDependency.class);
185-
} catch (IOException e) {
186-
throw new RuntimeException(e);
185+
} catch (Exception e) {
186+
throw new BuildException("Failed to parse vendor dependency: " + f.getName(), e);
187187
}
188188
}
189189

0 commit comments

Comments
 (0)