blob: e2bd61b18b2af865992de39731dbd66aad09e3a7 [file] [log] [blame] [raw]
package net.querz.nbt.io;
public class ParseException extends RuntimeException {
public ParseException(String msg) {
super(msg);
}
public ParseException(String msg, String value, int index) {
super(msg + " at: " + formatError(value, index));
}
private static String formatError(String value, int index) {
StringBuilder builder = new StringBuilder();
int i = Math.min(value.length(), index);
if (i > 35) {
builder.append("...");
}
builder.append(value, Math.max(0, i - 35), i);
builder.append("<--[HERE]");
return builder.toString();
}
}