How to use the yerror.wrap function in yerror

To help you get started, we’ve selected a few yerror 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 nfroidure / jsarch / src / jsarch.js View on Github external
log('debug', 'Reading file at', filePath);

  try {
    content = await fs.readFileAsync(filePath, 'utf-8');

    log('debug', 'File sucessfully read', filePath);

    if (SHEBANG_REGEXP.test(content)) {
      log('debug', 'Found a shebang, commenting it', filePath);
      content = '// Shebang commented by jsarch: ' + content;
    }
  } catch (err) {
    log('error', 'File read failure:', filePath);
    log('stack', 'Stack:', err.stack);
    throw YError.wrap(err, 'E_FILE_FAILURE', filePath);
  }

  try {
    const ast = parser(content);
    const architectureNotes = [];

    visit(ast, {
      visitComment: function(path) {
        const comment = path.value.value;
        const matches = ARCHITECTURE_NOTE_REGEXP.exec(comment);

        if (matches) {
          architectureNotes.push({
            num: matches[1],
            title: matches[2].trim(),
            content: comment.substr(matches[0].length).trim(),
github nfroidure / metapak / src / resolveModule.js View on Github external
return function resolveModule(metapakModuleName, packageConf) {
    try {
      // Cover the case a metapak plugin runs itself
      if (metapakModuleName === packageConf.name) {
        return path.dirname(require.resolve(`${PROJECT_DIR}/package`));
      }
      return path.dirname(require.resolve(`${metapakModuleName}/package`));
    } catch (err) {
      throw YError.wrap(err, 'E_MODULE_NOT_FOUND', metapakModuleName);
    }
  };
}
github nfroidure / metapak / src / metapak.js View on Github external
.catch(err => {
      throw YError.wrap(err, 'E_PACKAGE_NOT_FOUND', path);
    })
    .then(_parseJSON.bind(null, { log }, path));
github nfroidure / knifecycle / src / index.js View on Github external
);

      if (!serviceDescriptor) {
        debug('Provider did not return a descriptor:', serviceName);
        return Promise.reject(new YError(E_BAD_SERVICE_PROVIDER, serviceName));
      }
      debug('Successfully initialized a service descriptor:', serviceName);
      if (serviceDescriptor.fatalErrorPromise) {
        debug('Registering service descriptor error promise:', serviceName);
        siloContext.errorsPromises.push(serviceDescriptor.fatalErrorPromise);
      }
      siloContext.servicesDescriptors.set(serviceName, serviceDescriptor);
    } catch (err) {
      debug('Error initializing a service descriptor:', serviceName, err.stack);
      if (E_UNMATCHED_DEPENDENCY === err.code) {
        throw YError.wrap(
          ...[err, E_UNMATCHED_DEPENDENCY, serviceName].concat(err.params),
        );
      }
      throw err;
    }
    return serviceDescriptor;
  }
github nfroidure / metapak / src / metapak.js View on Github external
.catch(err => {
      throw YError.wrap(err, 'E_MALFORMED_PACKAGE', path);
    });
}
github nfroidure / jsarch / src / jsarch.js View on Github external
this.traverse(path);
      },
    });

    log('debug', 'File sucessfully processed', path);
    log(
      'debug',
      'Architecture notes found:',
      architectureNotes.map(a => a.title),
    );

    return architectureNotes;
  } catch (err) {
    log('error', 'File parse failure:', filePath);
    log('stack', 'Stack:', err.stack);
    throw YError.wrap(err, 'E_FILE_PARSE_FAILURE', filePath);
  }
}
github nfroidure / jsarch / src / jsarch.js View on Github external
log('debug', 'Processing pattern:', pattern);
        try {
          const files = await glob(pattern, {
            cwd,
            dot: true,
            nodir: true,
            absolute: true,
          });

          log('debug', 'Pattern sucessfully resolved', pattern);
          log('debug', 'Files:', files);
          return files;
        } catch (err) {
          log('error', 'Pattern failure:', pattern);
          log('stack', 'Stack:', err.stack);
          throw YError.wrap(err, 'E_PATTERN_FAILURE', pattern);
        }
      }),
    ),

yerror

It helps to know why you got an error.

MIT
Latest version published 1 year ago

Package Health Score

60 / 100
Full package analysis

Popular yerror functions