region gpf.interfaces.IReadableStream 
Process error that occurred during the stream reading

@param {Error} e Error coming from read
@return {Promise} Read result replacement
@since 0.2.4
428311
function (e) {
                if (e instanceof java.util.NoSuchElementException || e.message.startsWith("java.util.NoSuchElementException")) {
                    // Empty stream
                    return Promise.resolve();
                }
                return Promise.reject(e);
            }
505259
function handleError(promise) {
      if (canHandleError) {
        return promise.catch(function(err) {
          if (ctx) {
            ctx.error = err;
            if (ctx.emit) ctx.emit('error', ctx);
          } else {
            ctx = { error: err };
          }
          return onError(ctx, next).catch(function(err) {
            // Log catched error in onError
            logError(`[${new Date()}] ${err.name || err.message} \n ${err.stack}`);
          });
        });
      } else {
        return promise;
      }
    }
1268757
function readStream(stream) {
  return new Promise(function(resolve) {
    stream.pipe(concat(function(data) {
      resolve(data.toString().trim());
    }));
  });
}
683509
function readCallback(err, event) {
    if (err) {
      self.terminate();
      return;
    }
    if (self.finished) {
      self.push(null);
      return;
    }
    var data = event.read;
    var deserialized;
    try {
      deserialized = self.deserialize(data);
    } catch (e) {
      e.code = constants.status.INTERNAL;
      self.emit('error', e);
      return;
    }
    if (self.push(deserialized) && data !== null) {
      var read_batch = {};
      read_batch[grpc.opType.RECV_MESSAGE] = true;
      self.call.startBatch(read_batch, readCallback);
    } else {
      self.reading = false;
    }
  }
316224
async function* streamToGenerator(stream) {
  let promise;

  stream.on('data', data => promise.resolve(data));
  stream.once('end', () => promise.resolve(null));

  stream.on('error', error => {
    stream.removeAllListeners();
    promise.reject(error);
  });

  while (true) {
    promise = defer();

    yield promise;
  }
}
1007400
function readFile(fileName) {
	if (/^https?:/.test(fileName)) {
		return readFileFromURL(fileName);
	}

	return new Promise((resolve, reject) => {
		fs.readFile(fileName, (err, content) => err ? reject(err) : resolve(content));
	});
}
1261044
function _gpfReadNashorn (path) {
    var javaPath = java.nio.file.Paths.get(path);
    if (java.nio.file.Files.exists(javaPath)) {
        return new Promise(function (resolve, reject) {
            var javaInputStream = java.nio.file.Files.newInputStream(javaPath),
                iStreamReader = new _GpfStreamJavaReadable(javaInputStream),
                iWritableString = new _GpfStreamWritableString();
            return iStreamReader.read(iWritableString)
                .then(function () {
                    resolve(iWritableString.toString());
                })["catch"](reject);
        });
    }
    return Promise.reject(new Error("File not found")); // To be improved
}
219067
function promiseReadFile(path, encoding = 'utf-8') {
  return new Promise((resolve, reject) => {
    fs.readFile(path, encoding, (err, content) => {
      if (err) reject(err);

      resolve({
        path,
        fileName: path.split('/').pop(),
        content
      });
    });
  });
}
443908
function read(description, options, callback) {
  var file = vfile(description)

  if (!callback && typeof options === 'function') {
    callback = options
    options = null
  }

  if (!callback) {
    return new Promise(executor)
  }

  executor(resolve, callback)

  function resolve(result) {
    callback(null, result)
  }

  function executor(resolve, reject) {
    var fp

    try {
      fp = path.resolve(file.cwd, file.path)
    } catch (error) {
      return reject(error)
    }

    fs.readFile(fp, options, done)

    function done(error, res) {
      if (error) {
        reject(error)
      } else {
        file.contents = res
        resolve(file)
      }
    }
  }
}
37855
protected final void error(final HttpServletResponse httpServletResponse, final Throwable e) {
        httpServletResponse.setContentType("text/plain");
        httpServletResponse.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
        try (PrintWriter out = httpServletResponse.getWriter()) {
            out.println("Error while processing request:");
            LOGGER.error("Error while processing request", e);
        } catch (IOException ex) {
            throw ExceptionUtils.getRuntimeException(ex);
        }
    }
133949
public void handleExceptionRead(Exception e)
      {
        final String mName = "handleExceptionRead";
        
        logger.finer("RETRYHANDLE: in retryhandler handle exception on a read:" + e.toString());

        if(logger.isLoggable(Level.FINER)) 
          logger.logp(Level.FINE, className, mName, e.getClass().getName() + "; " + this.toString());
        
        if (!isRetryLimitReached() && excMatcher.isSkippableOrRetryable(e))
        {
           retryType = RETRY_READ;
           _retryException = e;
          // Retry it.  Log it.  Call the RetryListener.
          ++_retryCount;
          logRetry(e);

          if (_retryReadListeners != null) {
              for (RetryReadListenerProxy retryReadListenerProxy : _retryReadListeners) {
                  retryReadListenerProxy.onRetryReadException(e);
                }
          }
        }
        else
        {
          // No retry.  Throw it back.
          if(logger.isLoggable(Level.FINER)) 
            logger.logp(Level.FINE, className, mName, "No retry.  Rethrow", e);
            throw new BatchContainerRuntimeException(e);
        }

        if(logger.isLoggable(Level.FINER)) 
          logger.exiting(className, mName, e);
      }
165498
function readStream (stream, encoding, length, limit, callback) {
  var complete = false
  var sync = true

  // check the length and limit options.
  // note: we intentionally leave the stream paused,
  // so users should handle the stream themselves.
  if (limit !== null && length !== null && length > limit) {
    return done(createError(413, 'request entity too large', {
      expected: length,
      length: length,
      limit: limit,
      type: 'entity.too.large'
    }))
  }

  // streams1: assert request encoding is buffer.
  // streams2+: assert the stream encoding is buffer.
  //   stream._decoder: streams1
  //   state.encoding: streams2
  //   state.decoder: streams2, specifically < 0.10.6
  var state = stream._readableState
  if (stream._decoder || (state && (state.encoding || state.decoder))) {
    // developer error
    return done(createError(500, 'stream encoding should not be set', {
      type: 'stream.encoding.set'
    }))
  }

  var received = 0
  var decoder

  try {
    decoder = getDecoder(encoding)
  } catch (err) {
    return done(err)
  }

  var buffer = decoder
    ? ''
    : []

  // attach listeners
  stream.on('aborted', onAborted)
  stream.on('close', cleanup)
  stream.on('data', onData)
  stream.on('end', onEnd)
  stream.on('error', onEnd)

  // mark sync section complete
  sync = false

  function done () {
    var args = new Array(arguments.length)

    // copy arguments
    for (var i = 0; i < args.length; i++) {
      args[i] = arguments[i]
    }

    // mark complete
    complete = true

    if (sync) {
      process.nextTick(invokeCallback)
    } else {
      invokeCallback()
    }

    function invokeCallback () {
      cleanup()

      if (args[0]) {
        // halt the stream on error
        halt(stream)
      }

      callback.apply(null, args)
    }
  }

  function onAborted () {
    if (complete) return

    done(createError(400, 'request aborted', {
      code: 'ECONNABORTED',
      expected: length,
      length: length,
      received: received,
      type: 'request.aborted'
    }))
  }

  function onData (chunk) {
    if (complete) return

    received += chunk.length

    if (limit !== null && received > limit) {
      done(createError(413, 'request entity too large', {
        limit: limit,
        received: received,
        type: 'entity.too.large'
      }))
    } else if (decoder) {
      buffer += decoder.write(chunk)
    } else {
      buffer.push(chunk)
    }
  }

  function onEnd (err) {
    if (complete) return
    if (err) return done(err)

    if (length !== null && received !== length) {
      done(createError(400, 'request size did not match content length', {
        expected: length,
        length: length,
        received: received,
        type: 'request.size.invalid'
      }))
    } else {
      var string = decoder
        ? buffer + (decoder.end() || '')
        : Buffer.concat(buffer)
      done(null, string)
    }
  }

  function cleanup () {
    buffer = null

    stream.removeListener('aborted', onAborted)
    stream.removeListener('data', onData)
    stream.removeListener('end', onEnd)
    stream.removeListener('error', onEnd)
    stream.removeListener('close', cleanup)
  }
}
713735
function IncomingPromise(responseStream, promiseHeaders) {
  var stream = new Readable();
  stream._read = noop;
  stream.push(null);
  stream._log = responseStream._log;

  IncomingRequest.call(this, stream);

  this._onHeaders(promiseHeaders);

  this._responseStream = responseStream;

  var response = new IncomingResponse(this._responseStream);
  response.once('ready', this.emit.bind(this, 'response', response));

  this.stream.on('promise', this._onPromise.bind(this));
}
1163337
protected IOException toIoException(Exception e) {
        if (e instanceof IOException) {
            return (IOException) e;
        } else {
            return new IOException("Unexpected failure", e);
        }
    }
608999
function onError(e) {
    if (!inBrowser) {
        return {};
    }

    let response = {};
    if (e.response) {
        response = e.response.data;
    }

    throw Object.assign({
        statusCode: 500,
        message: 'Request error'
    }, response);
}
920358
async function readFile(path, encoding) {
	const url = browser.extension.getURL(realpath(path));

	return new Promise((resolve, reject) => {
		const xhr = new global.XMLHttpRequest;
		xhr.responseType = encoding == null ? 'arraybuffer' : 'text';
		xhr.addEventListener('load', () => resolve(xhr.response));
		xhr.addEventListener('error', reject);
		xhr.open('GET', url);
		xhr.send();
	});
}
971274
function readFile(e) {
  const file = e.currentTarget.files && e.currentTarget.files[0];
  const reader = new FileReader();

  reader.onload = event => ArtBoard.loadANSI(event.target.result);
  if (file) reader.readAsText(file);
}