for (int i = max(pos-10, 0), x = min(pos + 10, b.limit()); i < x; i++) {
sb.append(String.format("%02x ", b.get(i)));
}
// TODO post-1.0 need HgBadDataException (not InvalidState but smth closer to data stream error)
// but don't want to add class for the single use now
throw new HgInvalidStateException(String.format("Inconsistent newline characters in the stream %s (char 0x%x, local index:%d)", sb.toString(), b.get(pos), pos));
}