mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 16:25:36 +00:00
Say where a missing snippet reference is read from
A reference is snippet/<name>, a file below snippet/<snippet folder>/. A pack still written as snippet/decorator/bush, in the layout from before the folder was iris/decorant/decorator, was reported as having no file snippet/iris/decorant/decorator/decorator/bush.json, which reads like a doubled path in the lookup. The lookup is right; the message now names the folder the name is relative to.
This commit is contained in:
1 parent
28d9c34dd2
commit
ce7f782561
2 files changed
+15
-1
No files matched your search
@@ -377,7 +377,8 @@ public final class ModuleSettingsDecoder {
|
||||
Path folder = packFolder.resolve(SNIPPET_FOLDER).resolve(snippetFolder).normalize();
|
||||
Path file = folder.resolve(snippetName(snippetFolder, reference) + JSON_EXTENSION).normalize();
|
||||
if (!file.startsWith(folder) || !Files.isRegularFile(file)) {
|
||||
throw new JsonParseException("Snippet " + reference + " has no file " + packFolder.relativize(file));
|
||||
throw new JsonParseException("Snippet " + reference + " has no file " + packFolder.relativize(file)
|
||||
+ "; a snippet reference names a file below " + SNIPPET_FOLDER + "/" + snippetFolder + "/");
|
||||
}
|
||||
try {
|
||||
return Files.readString(file);
|
||||
|
||||
@@ -174,6 +174,19 @@ public class ModuleSettingsDecoderTest {
|
||||
assertTrue(missing.getMessage(), missing.getMessage().contains("Snippet snippet/narrow has no file snippet/moss-patch/narrow.json"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aReferenceIsReadBelowTheSnippetFolderAndAMissingFileSaysSo() throws IOException {
|
||||
Path oldLayout = Files.createDirectories(packFolder.resolve("snippet/patches"));
|
||||
Files.writeString(oldLayout.resolve("wide.json"), "{\"size\": 9}");
|
||||
|
||||
IllegalArgumentException missing = assertThrows(IllegalArgumentException.class,
|
||||
() -> moss("{\"moss\": {\"patch\": \"snippet/patches/wide\"}}"));
|
||||
|
||||
assertTrue(missing.getMessage(), missing.getMessage().contains(
|
||||
"Snippet snippet/patches/wide has no file snippet/moss-patch/patches/wide.json; "
|
||||
+ "a snippet reference names a file below snippet/moss-patch/"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void snippetReferencesMayNameTheSnippetFolderAsIrisSnippetsDo() throws IOException {
|
||||
Path snippets = Files.createDirectories(packFolder.resolve("snippet/moss-patch"));
|
||||
|
||||
Reference in new issue
Block a user