How to use the level-errors.EncodingError function in level-errors

To help you get started, we’ve selected a few level-errors examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Level / encoding-down / index.js View on Github external
this.db.get(key, opts, function (err, value) {
    if (err) return cb(err)
    try {
      value = self.codec.decodeValue(value, opts)
    } catch (err) {
      return cb(new EncodingError(err))
    }
    cb(null, value)
  })
}
github dominictarr / level-sublevel / read-stream.js View on Github external
it.next(function(err, key, value) {
        if (err) {
          return callback(err);
        }
        if (key === undefined && value === undefined) {
          return callback(err, key, value);
        }
        var data;
        try {
          data = makeData(key, value);
        } catch (err) {
          return callback(new EncodingError(err));
        }
        if (options.keys !== false && options.values === false) {
          return callback(err, data, value);
        }
        if (options.keys === false && options.values !== false) {
          return callback(err, key, data);
        }
        return callback(err, data.key, data.value);
      });
    },