How to use the level-errors.LevelUPError 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 DigixGlobal / truffle-lightwallet-provider / node_modules / levelup / lib / leveldown.js View on Github external
function requireError (e) {
  var template = 'Failed to require LevelDOWN (%s). Try `npm install leveldown` if it\'s missing'
  return new LevelUPError(format(template, e.message))
}
github DigixGlobal / truffle-lightwallet-provider / node_modules / levelup / lib / leveldown.js View on Github external
function getLevelDOWN () {
  if (leveldown) { return leveldown }

  var requiredVersion = require('../package.json').devDependencies.leveldown
  var leveldownVersion

  try {
    leveldownVersion = require('leveldown/package.json').version
  } catch (e) {
    throw requireError(e)
  }

  if (!require('semver').satisfies(leveldownVersion, requiredVersion)) {
    throw new LevelUPError(
        'Installed version of LevelDOWN (' +
      leveldownVersion +
      ') does not match required version (' +
      requiredVersion +
      ')'
    )
  }

  try {
    leveldown = require('leveldown')
    return leveldown
  } catch (e) {
    throw requireError(e)
  }
}