How to use the ono.ono 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
}

      // 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}"`));
      }
    }));
  }
github APIDevTools / json-schema-ref-parser / lib / util / yaml.js View on Github external
stringify: function yamlStringify (value, replacer, space) {
    try {
      let indent = (typeof space === "string" ? space.length : space) || 2;
      return yaml.safeDump(value, { indent });
    }
    catch (e) {
      if (e instanceof Error) {
        throw e;
      }
      else {
        // https://github.com/nodeca/js-yaml/issues/153
        throw ono(e, e.message);
      }
    }
  }
};
github APIDevTools / json-schema-ref-parser / lib / util / yaml.js View on Github external
parse: function yamlParse (text, reviver) {
    try {
      return yaml.safeLoad(text);
    }
    catch (e) {
      if (e instanceof Error) {
        throw e;
      }
      else {
        // https://github.com/nodeca/js-yaml/issues/153
        throw ono(e, e.message);
      }
    }
  },
github APIDevTools / swagger-parser / online / src / js / parser.js View on Github external
let results = swaggerParser.$refs.values();
        Object.keys(results).forEach((key) => {
          editors.showResult(key, results[key]);
        });
      })
      .catch((err) => {
        editors.showError(ono(err));
        analytics.trackError(err);
      });

    // Track the operation
    counters[method]++;
    analytics.trackEvent("button", "click", method, counters[method]);
  }
  catch (err) {
    editors.showError(ono(err));
    analytics.trackError(err);
  }
}
github APIDevTools / swagger-parser / online / src / js / parser.js View on Github external
.catch((err) => {
        editors.showError(ono(err));
        analytics.trackError(err);
      });

ono

Throw better errors.

MIT
Latest version published 4 years ago

Package Health Score

65 / 100
Full package analysis