GithubHelp home page GithubHelp logo

Unclear errors about ncp HOT 2 CLOSED

avianflu avatar avianflu commented on July 17, 2024
Unclear errors

from ncp.

Comments (2)

jprichardson avatar jprichardson commented on July 17, 2024

Agreed. Passing an array of errors is poor Node.js convention. Anyway you would modify it to have the callback fire with the first encountered error?

from ncp.

spion avatar spion commented on July 17, 2024

The error is on line 198 in ncp.js in the onError handler

if (options.stopOnError) {
  return callback(err);
}
else if (!errs && options.errs) {
  errs = fs.createWriteStream(options.errs);
}
else if (!errs) {
  errs = [];
}
else if (options.errs) { // this is the problem
  if (typeof errs.write === 'undefined') {
    errs.push(err);
  }
  else { 
    errs.write(err.stack + '\n\n');
  }
}
return cb();

This logic doesn't work properly and the options used there are undocumented. However, its clear that

else if (options.errs) { 

is incorrect - it means that if an errs option is not provided, no errors will ever be pushed into the errs array.

To fix this, line 198 should be simply removed, along with its closing brace. Its not necessary to check for anything there - the errs array (or stream) is already defined and errors can be pushed (or written) to it.

from ncp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.