From ce7f78256133daa03d75080a5d77a4f4a5352b2b Mon Sep 17 00:00:00 2001 From: piexel Date: Fri, 6 Nov 2026 14:30:27 +0100 Subject: [PATCH] Say where a missing snippet reference is read from A reference is snippet/, a file below snippet//. 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. --- .../iris/core/modules/ModuleSettingsDecoder.java | 3 ++- .../core/modules/ModuleSettingsDecoderTest.java | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/art/arcane/iris/core/modules/ModuleSettingsDecoder.java b/core/src/main/java/art/arcane/iris/core/modules/ModuleSettingsDecoder.java index 33c438ed2..413201615 100644 --- a/core/src/main/java/art/arcane/iris/core/modules/ModuleSettingsDecoder.java +++ b/core/src/main/java/art/arcane/iris/core/modules/ModuleSettingsDecoder.java @@ -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); diff --git a/core/src/test/java/art/arcane/iris/core/modules/ModuleSettingsDecoderTest.java b/core/src/test/java/art/arcane/iris/core/modules/ModuleSettingsDecoderTest.java index 476168bb7..6b873142b 100644 --- a/core/src/test/java/art/arcane/iris/core/modules/ModuleSettingsDecoderTest.java +++ b/core/src/test/java/art/arcane/iris/core/modules/ModuleSettingsDecoderTest.java @@ -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"));