How to use the common-errors.ArgumentNullError function in common-errors

To help you get started, we’ve selected a few common-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 pandawing / node-run-yo / lib / mkdir-in-temp.js View on Github external
return new Promise(function (resolve, reject) {
    if (!value) {
      reject(new errors.ArgumentNullError('value'));
      return;
    }
    ['dir'].forEach(function (key) {
      if(!value.hasOwnProperty(key) || !value[key]) {
        reject(new errors.ArgumentNullError(key));
        return;
      }
    });

    var targetDir = removeTrailingSlash(path.normalize(value['dir']));
    if (targetDir.split(path.sep).indexOf('..') !== -1) {
      reject(new errors.ArgumentError('dir has .. directory'));
      return;
    }

    tmp.setGracefulCleanup();
github pandawing / node-run-yo / lib / app-compile-dir.js View on Github external
return new Promise(function (resolve, reject) {
    if (!value) {
      reject(new errors.ArgumentNullError('value'));
      return;
    }
    ['input', 'packageName'].forEach(function (key) {
      if(!value.hasOwnProperty(key) || !value[key]) {
        reject(new errors.ArgumentNullError(key));
        return;
      }
    });
    var packageName = value['packageName'];
    var input = removeTrailingSeparator(value['input']);
    if (!isPackage(packageName)) {
      reject(new errors.ArgumentError(packageName + 'is not package'));
      return;
    }
    var split = path.normalize(input).split(path.sep);
    var inputLast = split[split.length - 1];
github pandawing / node-run-yo / lib / app-compile-dir.js View on Github external
['input', 'packageName'].forEach(function (key) {
      if(!value.hasOwnProperty(key) || !value[key]) {
        reject(new errors.ArgumentNullError(key));
        return;
      }
    });
    var packageName = value['packageName'];
github pandawing / node-run-yo / lib / get-object-field.js View on Github external
return new Promise(function (resolve, reject) {
    if (!value) {
      reject(new errors.ArgumentNullError('value'));
      return;
    }
    if(!value.hasOwnProperty('data') || !value['data']) {
      reject(new errors.ArgumentNullError('data'));
      return;
    }
    if(!value.hasOwnProperty('field') || !value['field']) {
      reject(new errors.ArgumentNullError('field'));
      return;
    }
    resolve(value['data'][value['field']]);
  });
};
github pandawing / node-run-yo / lib / get-object-field.js View on Github external
return new Promise(function (resolve, reject) {
    if (!value) {
      reject(new errors.ArgumentNullError('value'));
      return;
    }
    if(!value.hasOwnProperty('data') || !value['data']) {
      reject(new errors.ArgumentNullError('data'));
      return;
    }
    if(!value.hasOwnProperty('field') || !value['field']) {
      reject(new errors.ArgumentNullError('field'));
      return;
    }
    resolve(value['data'][value['field']]);
  });
};
github pandawing / node-run-yo / lib / mkdir-in-temp.js View on Github external
['dir'].forEach(function (key) {
      if(!value.hasOwnProperty(key) || !value[key]) {
        reject(new errors.ArgumentNullError(key));
        return;
      }
    });
github pandawing / node-run-yo / lib / get-object-field.js View on Github external
return new Promise(function (resolve, reject) {
    if (!value) {
      reject(new errors.ArgumentNullError('value'));
      return;
    }
    if(!value.hasOwnProperty('data') || !value['data']) {
      reject(new errors.ArgumentNullError('data'));
      return;
    }
    if(!value.hasOwnProperty('field') || !value['field']) {
      reject(new errors.ArgumentNullError('field'));
      return;
    }
    resolve(value['data'][value['field']]);
  });
};
github pandawing / node-run-yo / lib / read-json-file.js View on Github external
return new Promise(function(resolve, reject) {
    if (!value) {
      reject(new errors.ArgumentNullError('value'));
      return;
    }
    if(!value.hasOwnProperty('path') || !value['path']) {
      reject(new errors.ArgumentNullError('path'));
      return;
    }

    var filePath = path.normalize(value['path']);
    fs.readFile(filePath, 'utf8', function (err, data) {
      if (err) {
        reject(new errors.io.FileLoadError(filePath));
        return;
      }
      try {
        var contents = JSON.parse(data);
      } catch (error) {
        reject(new errors.Error('JSON.parse', error));
        return;
      }
      resolve(contents);
github pandawing / node-run-yo / lib / read-json-file.js View on Github external
return new Promise(function(resolve, reject) {
    if (!value) {
      reject(new errors.ArgumentNullError('value'));
      return;
    }
    if(!value.hasOwnProperty('path') || !value['path']) {
      reject(new errors.ArgumentNullError('path'));
      return;
    }

    var filePath = path.normalize(value['path']);
    fs.readFile(filePath, 'utf8', function (err, data) {
      if (err) {
        reject(new errors.io.FileLoadError(filePath));
        return;
      }
      try {
        var contents = JSON.parse(data);
      } catch (error) {