How to use level-errors - 10 common examples

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 deanlandolt / bytespace / index.js View on Github external
function handler(err, v) {
        // sanitize full keypath for notFound errors
        if (err && err.notFound || NOT_FOUND.test(err)) {
          try {
            err = new NotFoundError('Key not found in database [' + k + ']')
          }
          catch (_) {}
        }

        cb(err, v)
      }
    }
github DigixGlobal / truffle-lightwallet-provider / node_modules / levelup / lib / levelup.js View on Github external
var extend = require('xtend')
var prr = require('prr')
var DeferredLevelDOWN = require('deferred-leveldown')
var IteratorStream = require('level-iterator-stream')
var Batch = require('./batch')
var Codec = require('level-codec')
var getLevelDOWN = require('./leveldown')
var errors = require('level-errors')
var util = require('./util')

var WriteError = errors.WriteError
var ReadError = errors.ReadError
var NotFoundError = errors.NotFoundError
var OpenError = errors.OpenError
var EncodingError = errors.EncodingError
var InitializationError = errors.InitializationError
var LevelUPError = errors.LevelUPError

var getOptions = util.getOptions
var defaultOptions = util.defaultOptions
var dispatchError = util.dispatchError

function getCallback (options, callback) {
  return typeof options === 'function' ? options : callback
}

// Possible LevelUP#_status values:
//  - 'new'     - newly created, not opened or closed
//  - 'opening' - waiting for the database to be opened, post open()
//  - 'open'    - successfully opened the database, available for use
//  - 'closing' - waiting for the database to be closed, post close()
//  - 'closed'  - database has been successfully closed, should not be
github DigixGlobal / truffle-lightwallet-provider / node_modules / levelup / lib / levelup.js View on Github external
var inherits = require('util').inherits
var deprecate = require('util').deprecate
var extend = require('xtend')
var prr = require('prr')
var DeferredLevelDOWN = require('deferred-leveldown')
var IteratorStream = require('level-iterator-stream')
var Batch = require('./batch')
var Codec = require('level-codec')
var getLevelDOWN = require('./leveldown')
var errors = require('level-errors')
var util = require('./util')

var WriteError = errors.WriteError
var ReadError = errors.ReadError
var NotFoundError = errors.NotFoundError
var OpenError = errors.OpenError
var EncodingError = errors.EncodingError
var InitializationError = errors.InitializationError
var LevelUPError = errors.LevelUPError

var getOptions = util.getOptions
var defaultOptions = util.defaultOptions
var dispatchError = util.dispatchError

function getCallback (options, callback) {
  return typeof options === 'function' ? options : callback
}

// Possible LevelUP#_status values:
//  - 'new'     - newly created, not opened or closed
//  - 'opening' - waiting for the database to be opened, post open()
//  - 'open'    - successfully opened the database, available for use
github DigixGlobal / truffle-lightwallet-provider / node_modules / levelup / lib / levelup.js View on Github external
var EventEmitter = require('events').EventEmitter
var inherits = require('util').inherits
var deprecate = require('util').deprecate
var extend = require('xtend')
var prr = require('prr')
var DeferredLevelDOWN = require('deferred-leveldown')
var IteratorStream = require('level-iterator-stream')
var Batch = require('./batch')
var Codec = require('level-codec')
var getLevelDOWN = require('./leveldown')
var errors = require('level-errors')
var util = require('./util')

var WriteError = errors.WriteError
var ReadError = errors.ReadError
var NotFoundError = errors.NotFoundError
var OpenError = errors.OpenError
var EncodingError = errors.EncodingError
var InitializationError = errors.InitializationError
var LevelUPError = errors.LevelUPError

var getOptions = util.getOptions
var defaultOptions = util.defaultOptions
var dispatchError = util.dispatchError

function getCallback (options, callback) {
  return typeof options === 'function' ? options : callback
}

// Possible LevelUP#_status values:
//  - 'new'     - newly created, not opened or closed
github maxogden / dat-core / index.js View on Github external
var notFound = function (key) {
  return new errors.NotFoundError('Key not found in database [' + key + ']')
}
github tradle / tim-old-engine / src / msgDB.js View on Github external
return db.byRootHash(rootHash, function (err, entries) {
      if (err) return cb(err)

      var found = entries.some(function (e) {
        if (e[CUR_HASH] === curHash) {
          cb(null, e)
        }
      })

      if (!found) {
        cb(null, new levelErrs.NotFoundError())
      }
    })
  })
github smallhelm / level-fact-base / level-hash-index.js View on Github external
put(val, function(err, d){
        if(err){
          callback(err);
        }else if(d.is_new){
          callback(new NotFoundError("No hash exists for that value"));
        }else{
          callback(null, d.hash);
        }
      });
    },
github tradle / tim-old-engine / lib / msgDB.js View on Github external
}), function (err, entries) {
      if (err) return cb(err)
      if (!entries || !entries.length) {
        return cb(new levelErrs.NotFoundError())
      }

      return cb(null, entries)
    })
  })
github tradle / engine / lib / indexer.js View on Github external
search(prop, value, function (err, results) {
        if (!err && !results.length) {
          err = new levelErrors.NotFoundError()
        }

        cb(err, results[0])
      })
    }
github dominictarr / level-sublevel / shell.js View on Github external
nut.get(key, prefix, mergeOpts(opts), function (err, value) {
      if(err) cb(new errors.NotFoundError('Key not found in database', err))
      else cb(null, value)
    })
  }