How to use errs - 10 common examples

To help you get started, we’ve selected a few errs 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 pkgcloud / pkgcloud / lib / pkgcloud / mongolab / database / client / accounts.js View on Github external
exports.getAccount = function getAccount(name, callback) {
  // Check for options
  if (typeof name === 'function') {
    return errs.handle(errs.create({
      message: 'Name required for view an account.'
    }), name);
  }

  this._request({ path: 'accounts/' + name }, function (err, body) {
    return err
      ? callback(err)
      : callback(null, body.adminUser);
  });
};
github pkgcloud / pkgcloud / lib / pkgcloud / mongolab / database / client / databases.js View on Github external
exports.getDatabases = function getDatabases(owner, callback) {
  // Check for options
  if (typeof owner === 'function') {
    return errs.handle(errs.create({
      message: 'Name required for delete an account.'
    }), owner);
  }

  this._request({ path: 'accounts/' + owner + '/databases' }, function (err, body) {
    return err
      ? callback(err)
      : callback(null, body);
  });
};
github pkgcloud / pkgcloud / lib / pkgcloud / rackspace / database / client / databases.js View on Github external
exports.getDatabases = function getDatabases(options, callback) {
  var self = this,
      completeUrl = {},
      requestOptions = {};

  if (typeof options === 'function') {
    return errs.handle(errs.create({
      message: 'An instance is required for get all databases.'
    }), Array.prototype.slice.call(arguments).pop());
  }
  // Check for instance
  if (!options['instance']) {
    return errs.handle(errs.create({
      message: 'An instance is required for get all databases.'
    }), Array.prototype.slice.call(arguments).pop());
  }
  // The limit parameter for truncate results
  if (options && options.limit) {
    completeUrl.limit = options.limit;
  }
  // The offset
  if (options && options.offset) {
    completeUrl.marker = options.offset;
github pkgcloud / pkgcloud / lib / pkgcloud / mongolab / database / client / accounts.js View on Github external
exports.createAccount = function createAccount(options, callback) {
  // Check for options
  if (typeof options === 'function') {
    return errs.handle(errs.create({
      message: 'Options required for create an account.'
    }), options);
  }

  if (!options['name']) {
    return errs.handle(errs.create({
      message: 'options. Name is a required argument'
    }), callback);
  }

  if (!options['email']) {
    return errs.handle(errs.create({
      message: 'options. Email is a required argument'
    }), callback);
  }
github pkgcloud / pkgcloud / lib / pkgcloud / rackspace / database / client / instances.js View on Github external
exports.createInstance = function createInstance(options, callback) {
  var self = this,
      flavorRef,
      size;

  // Check for options
  if (!options || typeof options === 'function') {
    return errs.handle(errs.create({
      message: 'Options required for create an instance.'
    }), options);
  }

  if (!options['name']) {
    return errs.handle(errs.create({
      message: 'options. name is a required argument'
    }), callback);
  }

  if (!options['flavor']) {
    return errs.handle(errs.create({
      message: 'options. flavor is a required argument'
    }), callback);
  }
github cloudant / nodejs-cloudant / lib / nano.js View on Github external
if (!parsed.message && (parsed.reason || parsed.error)) {
        parsed.message = (parsed.reason || parsed.error);
      }

      // fix cloudant issues where they give an erlang stacktrace as js
      delete parsed.stack;

      callback(errs.merge({
        message: 'couch returned ' + rh.statusCode,
        scope: 'couch',
        statusCode: rh.statusCode,
        request: req,
        headers: rh,
        errid: 'non_200'
      }, errs.create(parsed)));
    });
  }
github pkgcloud / pkgcloud / lib / pkgcloud / azure / utils / azureApi.js View on Github external
createVM = function (client, options, vmOptions, callback) {
  // check OS type of image to determine if we are creating a linux or windows VM
  switch (vmOptions.image.OSImage.OS.toLowerCase()) {
    case 'linux':
      createLinuxVM(client, options, vmOptions, callback);
      break;
    case 'windows':
      createWindowsVM(client, options, vmOptions, callback);
      break;
    default:
      callback(errs.create({message: 'Unknown Image OS: ' + vmOptions.image.OS}));
      break;
  }
};
github pkgcloud / pkgcloud / lib / pkgcloud / azure / utils / azureApi.js View on Github external
var createVM = function(client, options, vmOptions, callback) {
  // check OS type of image to determine if we are creating a linux or windows VM
  switch(vmOptions.image.OS.toLowerCase()) {
    case 'linux':
      createLinuxVM(client, options, vmOptions, callback);
      break;
    case 'windows':
      createWindowsVM(client, options, vmOptions, callback);
      break;
    default:
      callback(errs.create({message: 'Unknown Image OS: ' + vmOptions.image.OS}));
      break;
  }
};
github pkgcloud / pkgcloud / lib / pkgcloud / azure / compute / client / azure / azureServer.js View on Github external
AzureServer.prototype.createVM = function(callback) {
  // check OS type of image to determine if we are creating a linux or windows VM
  switch(this.image.OS.toLowerCase()) {
    case 'linux':
      this.createLinuxVM(callback);
      break;
    case 'windows':
      this.createWindowsVM(callback);
      break;
    default:
      callback(errs.create({message: 'Unknown Image OS: ' + this.image.OS}));
      break;
  }
};
github pkgcloud / pkgcloud / lib / pkgcloud / core / base / client.js View on Github external
return function (err, res, body) {
    if (err) {
      return callback(err);
    }

    var err2 = self._parseError(res, body);

    if (err2) {
      self.emit('log::error', 'Error during provider response', err2);
      return callback(errs.create(err2));
    }

    self.emit('log::trace', 'Provider Response', {
      href: res.request.uri.href,
      method: res.request.method,
      headers: res.headers,
      statusCode: res.statusCode
    });

    callback(err, body, res);
  };
};

errs

Simple error creation and passing utilities

MIT
Latest version published 9 years ago

Package Health Score

53 / 100
Full package analysis

Popular errs functions