GithubHelp home page GithubHelp logo

Comments (6)

tomas avatar tomas commented on July 19, 2024

Why are you sending an undefined url? What do you expect should happen? It should definitely throw.

from needle.

thomasmodeneis avatar thomasmodeneis commented on July 19, 2024

"What do you expect should happen? It should definitely throw.":
I expect this throw error but not like Cannot call method 'indexOf' of undefined. A cb with error message would be another choice.
"Why are you sending an undefined url?"
I just happen to have the issue when in a method the url was undefined for unknown reason and needle failed the whole batch as it was not expected scenario for me before!

from needle.

bendrucker avatar bendrucker commented on July 19, 2024

The standard behavior here would be to throw a TypeError for a bad argument and not to call a callback.

from needle.

thomasmodeneis avatar thomasmodeneis commented on July 19, 2024

I don't agree with throwing a TypeError.

For example request returns a cb with the error msg:

$ node testUriUndefined
[Error: options.uri is a required argument]

var request = require('request')
var options = {'url': undefined}
request(options, function (error, response, body) {
console.log(error);
});

from needle.

bendrucker avatar bendrucker commented on July 19, 2024

That's the convention adopted by all the built in Node APIs including fs, Stream, and others. Bad arguments (developer error) throw and everything else is passed to the callback.

from needle.

tomas avatar tomas commented on July 19, 2024

Yes, totally agree with Ben. If you're passing an invalid argument, you should get an exception in order to get your code fixed and/or perform the necessary checks to prevent that from hapenning. Callback errors are meant to contain errors in the request process. And remember that it is possible to call needle without passing a callback. :)

from needle.

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.