Fix #5 - Add field number to parse error messages

This commit is contained in:
Enrique Zamudio
2013-01-18 13:29:39 -06:00
parent d570eb4885
commit 913d74a133
15 changed files with 253 additions and 112 deletions
@@ -35,13 +35,16 @@ public class AlphaParseInfo extends AlphaNumericFieldParseInfo {
super(IsoType.ALPHA, len);
}
public IsoValue<?> parseBinary(byte[] buf, int pos, CustomField<?> custom)
throws ParseException, UnsupportedEncodingException {
public IsoValue<?> parseBinary(final int field, final byte[] buf, final int pos,
final CustomField<?> custom)
throws ParseException, UnsupportedEncodingException {
if (pos < 0) {
throw new ParseException(String.format("Invalid bin ALPHA position %d", pos), pos);
throw new ParseException(String.format("Invalid bin ALPHA field %d position %d",
field, pos), pos);
} else if (pos+length > buf.length) {
throw new ParseException(String.format("Insufficient data for bin %s field of length %d, pos %d",
type, length, pos), pos);
throw new ParseException(String.format(
"Insufficient data for bin %s field %d of length %d, pos %d",
type, field, length, pos), pos);
}
try {
if (custom == null) {
@@ -55,8 +58,9 @@ public class AlphaParseInfo extends AlphaNumericFieldParseInfo {
return v;
}
} catch (IndexOutOfBoundsException ex) {
throw new ParseException(String.format("Insufficient data for bin %s field of length %d, pos %d",
type, length, pos), pos);
throw new ParseException(String.format(
"Insufficient data for bin %s field %d of length %d, pos %d",
type, field, length, pos), pos);
}
}