/**
  * Read and return one byte from {@link #mIn}, and put it in {@link #mDiscourseLogger}.
  *
  * <p>Throws IOException() if reaches EOF. As long as logical response lines end with \r\n, we
  * shouldn't see EOF during parsing.
  */
 private int readByte() throws IOException {
   int next = mIn.read();
   if (next == -1) {
     throw newEOSException();
   }
   mDiscourseLogger.addReceivedByte(next);
   return next;
 }
 private void onParseError(Exception e) {
   // Read a few more bytes, so that the log will contain some more context, even if the parser
   // crashes in the middle of a response.
   // This also makes sure the byte in question will be logged, no matter where it crashes.
   // e.g. when parseAtom() peeks and finds at an unexpected char, it throws an exception
   // before actually reading it.
   // However, we don't want to read too much, because then it may get into an email message.
   try {
     for (int i = 0; i < 4; i++) {
       int b = readByte();
       if (b == -1 || b == '\n') {
         break;
       }
     }
   } catch (IOException ignore) {
   }
   Log.w(Logging.LOG_TAG, "Exception detected: " + e.getMessage());
   mDiscourseLogger.logLastDiscourse();
 }