More info in parsing exceptions
This commit is contained in:
@@ -55,7 +55,8 @@ public class LllbinParseInfo extends FieldParseInfo {
|
|||||||
l, field, pos), pos);
|
l, field, pos), pos);
|
||||||
} else if (l+pos+3 > buf.length) {
|
} else if (l+pos+3 > buf.length) {
|
||||||
throw new ParseException(String.format(
|
throw new ParseException(String.format(
|
||||||
"Insufficient data for LLLBIN field %d, pos %d", field, pos), pos);
|
"Insufficient data for LLLBIN field %d, pos %d len %d",
|
||||||
|
field, pos, l), pos);
|
||||||
}
|
}
|
||||||
byte[] binval = l == 0 ? new byte[0] : HexCodec.hexDecode(new String(buf, pos + 3, l));
|
byte[] binval = l == 0 ? new byte[0] : HexCodec.hexDecode(new String(buf, pos + 3, l));
|
||||||
if (custom == null) {
|
if (custom == null) {
|
||||||
@@ -68,7 +69,8 @@ public class LllbinParseInfo extends FieldParseInfo {
|
|||||||
new IsoValue<>(type, dec, 0, custom);
|
new IsoValue<>(type, dec, 0, custom);
|
||||||
} catch (IndexOutOfBoundsException ex) {
|
} catch (IndexOutOfBoundsException ex) {
|
||||||
throw new ParseException(String.format(
|
throw new ParseException(String.format(
|
||||||
"Insufficient data for LLLBIN field %d, pos %d", field, pos), pos);
|
"Insufficient data for LLLBIN field %d, pos %d len %d",
|
||||||
|
field, pos, l), pos);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
@@ -78,7 +80,8 @@ public class LllbinParseInfo extends FieldParseInfo {
|
|||||||
new IsoValue<>(type, dec, l, custom);
|
new IsoValue<>(type, dec, l, custom);
|
||||||
} catch (IndexOutOfBoundsException ex) {
|
} catch (IndexOutOfBoundsException ex) {
|
||||||
throw new ParseException(String.format(
|
throw new ParseException(String.format(
|
||||||
"Insufficient data for LLLBIN field %d, pos %d", field, pos), pos);
|
"Insufficient data for LLLBIN field %d, pos %d len %d",
|
||||||
|
field, pos, l), pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,15 +51,15 @@ public class LllvarParseInfo extends FieldParseInfo {
|
|||||||
throw new ParseException(String.format("Invalid LLLVAR length %d(%s) field %d pos %d",
|
throw new ParseException(String.format("Invalid LLLVAR length %d(%s) field %d pos %d",
|
||||||
len, new String(buf, pos, 3), field, pos), pos);
|
len, new String(buf, pos, 3), field, pos), pos);
|
||||||
} else if (len+pos+3 > buf.length) {
|
} else if (len+pos+3 > buf.length) {
|
||||||
throw new ParseException(String.format("Insufficient data for LLLVAR field %d, pos %d",
|
throw new ParseException(String.format("Insufficient data for LLLVAR field %d, pos %d len %d",
|
||||||
field, pos), pos);
|
field, pos, len), pos);
|
||||||
}
|
}
|
||||||
String _v;
|
String _v;
|
||||||
try {
|
try {
|
||||||
_v = len == 0 ? "" : new String(buf, pos + 3, len, getCharacterEncoding());
|
_v = len == 0 ? "" : new String(buf, pos + 3, len, getCharacterEncoding());
|
||||||
} catch (IndexOutOfBoundsException ex) {
|
} catch (IndexOutOfBoundsException ex) {
|
||||||
throw new ParseException(String.format(
|
throw new ParseException(String.format(
|
||||||
"Insufficient data for LLLVAR header, field %d pos %d", field, pos), pos);
|
"Insufficient data for LLLVAR header, field %d pos %d len %d", field, pos, len), pos);
|
||||||
}
|
}
|
||||||
//This is new: if the String's length is different from the specified length in the
|
//This is new: if the String's length is different from the specified length in the
|
||||||
//buffer, there are probably some extended characters. So we create a String from
|
//buffer, there are probably some extended characters. So we create a String from
|
||||||
|
|||||||
@@ -52,14 +52,16 @@ public class LlvarParseInfo extends FieldParseInfo {
|
|||||||
"Invalid LLVAR length %d, field %d pos %d", len, field, pos), pos);
|
"Invalid LLVAR length %d, field %d pos %d", len, field, pos), pos);
|
||||||
} else if (len+pos+2 > buf.length) {
|
} else if (len+pos+2 > buf.length) {
|
||||||
throw new ParseException(String.format(
|
throw new ParseException(String.format(
|
||||||
"Insufficient data for LLVAR field %d, pos %d", field, pos), pos);
|
"Insufficient data for LLVAR field %d, pos %d len %d",
|
||||||
|
field, pos, len), pos);
|
||||||
}
|
}
|
||||||
String _v;
|
String _v;
|
||||||
try {
|
try {
|
||||||
_v = len == 0 ? "" : new String(buf, pos + 2, len, getCharacterEncoding());
|
_v = len == 0 ? "" : new String(buf, pos + 2, len, getCharacterEncoding());
|
||||||
} catch (IndexOutOfBoundsException ex) {
|
} catch (IndexOutOfBoundsException ex) {
|
||||||
throw new ParseException(String.format(
|
throw new ParseException(String.format(
|
||||||
"Insufficient data for LLVAR header, field %d pos %d", field, pos), pos);
|
"Insufficient data for LLVAR header, field %d pos %d len %d",
|
||||||
|
field, pos, len), pos);
|
||||||
}
|
}
|
||||||
//This is new: if the String's length is different from the specified
|
//This is new: if the String's length is different from the specified
|
||||||
// length in the buffer, there are probably some extended characters.
|
// length in the buffer, there are probably some extended characters.
|
||||||
|
|||||||
Reference in New Issue
Block a user