Improve the message we get when we reach the end of stream
@@ -441,7 +441,12 @@ class ImapResponseParser {
}
}
- throw new IOException("readStringUntil(): end of stream reached");
+ throw new IOException("readStringUntil(): end of stream reached. " +
+ "Read: \"" + sb.toString() + "\" while waiting for " + formatChar(end));
+ }
+
+ private String formatChar(char value) {
+ return value < 32 ? "[" + Integer.toString(value) + "]" : "'" + value + "'";
}
private String readStringUntilEndOfLine() throws IOException {
