Improve requireTag exception messages

e15d7993ada7b26784471bdb0e9550228724d900

Co-Authored-By: Octavia Togami <2093023+octylFractal@users.noreply.github.com>
This commit is contained in:
N0tMyFaultOG 2020-11-13 22:09:36 +01:00
parent d44cceb1e9
commit 197389bd32

View File

@ -32,12 +32,14 @@ public abstract class NBTSchematicReader implements ClipboardReader {
protected static <T extends Tag> T requireTag(Map<String, Tag> items, String key, Class<T> expected) throws IOException {
if (!items.containsKey(key)) {
throw new IOException("Schematic file is missing a \"" + key + "\" tag");
throw new IOException("Schematic file is missing a \"" + key + "\" tag of type "
+ expected.getName());
}
Tag tag = items.get(key);
if (!expected.isInstance(tag)) {
throw new IOException(key + " tag is not of tag type " + expected.getName());
throw new IOException(key + " tag is not of tag type " + expected.getName() + ", got "
+ tag.getClass().getName() + " instead");
}
return expected.cast(tag);