Skip to content

Commit 25bd34a

Browse files
committed
Rename parseTag to readTag and throw IOException
1 parent b0eb067 commit 25bd34a

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

‎src/main/java/org/glavo/nbt/internal/SNBTCodecImpl.java‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,15 @@ public record SNBTCodecImpl() implements SNBTCodec {
2626
public static final SNBTCodecImpl DEFAULT = new SNBTCodecImpl();
2727

2828
@Override
29-
public Tag parseTag(CharSequence input, int startInclusive, int endExclusive) throws IllegalArgumentException {
30-
Tag tag = new SNBTParser(input, startInclusive, endExclusive).nextTag();
29+
public Tag readTag(CharSequence input, int startInclusive, int endExclusive) throws IOException {
30+
Tag tag;
31+
try {
32+
tag = new SNBTParser(input, startInclusive, endExclusive).nextTag();
33+
} catch (IllegalArgumentException e) {
34+
throw new IOException(e);
35+
}
3136
if (tag == null) {
32-
throw new IllegalArgumentException("Unexpected end of input");
37+
throw new IOException("Unexpected end of input");
3338
}
3439
return tag;
3540
}
@@ -45,7 +50,7 @@ public Tag readTag(Readable readable) throws IOException {
4550
buffer.clear();
4651
}
4752
try {
48-
return parseTag(builder);
53+
return readTag(builder);
4954
} catch (IllegalArgumentException e) {
5055
throw new IOException(e);
5156
}

‎src/main/java/org/glavo/nbt/io/SNBTCodec.java‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@ static SNBTCodec of() {
3333

3434
/// Parses a Stringified NBT data.
3535
///
36-
/// @throws IllegalArgumentException if the input is not a valid Stringified NBT data.
36+
/// @throws IOException if the input is not a valid Stringified NBT data.
3737
@Contract(pure = true)
38-
default Tag parseTag(CharSequence input) throws IllegalArgumentException {
39-
return parseTag(input, 0, input.length());
38+
default Tag readTag(CharSequence input) throws IOException {
39+
return readTag(input, 0, input.length());
4040
}
4141

4242
/// Parses a Stringified NBT data.
4343
///
4444
/// @throws IndexOutOfBoundsException if the range is out of bounds.
45-
/// @throws IllegalArgumentException if the input is not a valid Stringified NBT data.
45+
/// @throws IOException if the input is not a valid Stringified NBT data.
4646
@Contract(pure = true)
47-
Tag parseTag(CharSequence input, int startInclusive, int endExclusive) throws IllegalArgumentException;
47+
Tag readTag(CharSequence input, int startInclusive, int endExclusive) throws IOException;
4848

4949
/// Reads a Stringified NBT data from a readable source.
5050
///

0 commit comments

Comments
 (0)