How to use the ono.ono.uri function in ono

To help you get started, we’ve selected a few ono 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 APIDevTools / json-schema-ref-parser / lib / resolvers / file.js View on Github external
return new Promise(((resolve, reject) => {
      let path;
      try {
        path = url.toFileSystemPath(file.url);
      }
      catch (err) {
        reject(ono.uri(err, `Malformed URI: ${file.url}`));
      }

      // console.log('Opening file: %s', path);

      try {
        fs.readFile(path, (err, data) => {
          if (err) {
            reject(ono(err, `Error opening file "${path}"`));
          }
          else {
            resolve(data);
          }
        });
      }
      catch (err) {
        reject(ono(err, `Error opening file "${path}"`));

ono

Throw better errors.

MIT
Latest version published 4 years ago

Package Health Score

65 / 100
Full package analysis