Skip to content

Commit 50d8e37

Browse files
author
cube
committed
Improve error messages and extend regex pattern to also accept
oolite-source-1.92.1.zip
1 parent 51a33d4 commit 50d8e37

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

src/main/java/com/chaudhuri/ooliteaddonscanner2/AddonsUtil.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,19 @@ public static void readOolite(ExpansionCache cache, Registry registry) throws IO
310310
}
311311

312312
String tag = "latest";
313+
String url = null;
314+
Map<String, Object> manifest = null;
313315

314-
Map<String, Object> manifest = cache.getOoliteManifest(tag);
315-
String url = cache.getOoliteDownloadUrl(manifest);
316+
try {
317+
manifest = cache.getOoliteManifest(tag);
318+
} catch (Exception e) {
319+
throw new IllegalStateException("Could not get manifest for Oolite '" + tag+ "'", e);
320+
}
321+
try {
322+
url = cache.getOoliteDownloadUrl(manifest);
323+
} catch (Exception e) {
324+
throw new IllegalStateException("Could not get download url for Oolite from manifest", e);
325+
}
316326
try (InputStream olitezip = cache.getPluginInputStream(url); ZipInputStream zin = new ZipInputStream(olitezip)) {
317327
Expansion oxp = new Expansion();
318328
oxp.setDownloadUrl(url);

src/main/java/com/chaudhuri/ooliteaddonscanner2/ExpansionCache.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public Map<String, Object> getOoliteManifest(String tag) throws IOException, URI
205205
public String getOoliteDownloadUrl(Map<String, Object> manifest) {
206206
log.debug("getOoliteDownloadUrl({})", manifest);
207207

208-
Pattern pattern = Pattern.compile("oolite-source-\\d+\\.\\d+\\.zip");
208+
Pattern pattern = Pattern.compile("oolite-source-\\d+(\\.\\d+)*\\.zip");
209209

210210
List<Object> assets = (List<Object>)manifest.get("assets");
211211
for (Object oasset: assets) {
@@ -219,7 +219,8 @@ public String getOoliteDownloadUrl(Map<String, Object> manifest) {
219219
return assetUrlStr;
220220
}
221221
}
222-
throw new IllegalStateException("Could not find file matching "+pattern.pattern());
222+
log.error("Manifest: {}", manifest);
223+
throw new IllegalStateException("Could not find file matching "+pattern.pattern() +" in manifest's assets");
223224
}
224225

225226
/**

0 commit comments

Comments
 (0)