|
1 | 1 | package me.itzg.helpers.files; |
2 | 2 |
|
| 3 | +import com.fasterxml.jackson.core.JsonProcessingException; |
3 | 4 | import java.io.IOException; |
4 | 5 | import java.nio.file.Files; |
5 | 6 | import java.nio.file.Path; |
|
10 | 11 | import java.util.function.Consumer; |
11 | 12 | import java.util.stream.Collectors; |
12 | 13 | import java.util.stream.Stream; |
| 14 | +import lombok.extern.slf4j.Slf4j; |
13 | 15 | import me.itzg.helpers.json.ObjectMappers; |
14 | 16 | import org.slf4j.Logger; |
15 | 17 |
|
| 18 | +@Slf4j |
16 | 19 | public class Manifests { |
17 | 20 |
|
18 | 21 | private static final String SUFFIX = ".json"; |
@@ -112,13 +115,17 @@ public static boolean allFilesPresent(Path basePath, BaseManifest manifest, List |
112 | 115 | * |
113 | 116 | * @param outputDir directory where manifest and other module files are based |
114 | 117 | * @param id module identifier, such as "fabric" |
| 118 | + * @return the loaded manifest file or null if it didn't exist or was invalid content |
115 | 119 | */ |
116 | 120 | public static <M extends BaseManifest> M load(Path outputDir, String id, Class<M> manifestClass) { |
117 | 121 | final Path manifestPath = buildManifestPath(outputDir, id); |
118 | 122 | if (Files.exists(manifestPath)) { |
119 | 123 | final M manifest; |
120 | 124 | try { |
121 | 125 | manifest = ObjectMappers.defaultMapper().readValue(manifestPath.toFile(), manifestClass); |
| 126 | + } catch (JsonProcessingException e) { |
| 127 | + log.error("Failed to parse existing manifest file {}", manifestPath, e); |
| 128 | + return null; |
122 | 129 | } catch (IOException e) { |
123 | 130 | throw new ManifestException("Failed to load existing manifest from "+manifestPath, e); |
124 | 131 | } |
|
0 commit comments