How to use the common-errors.io 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 / read-json-file.js View on Github external
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);
    });
  });