Skip to content

Meaningful Errors On Invalid Input? #667

@jamescarr

Description

@jamescarr

Ran across this issue today with some user code on our site:

~  node
> var async = require('async')
undefined
> async.map(process.nosir, function() {}, function() {});
TypeError: Cannot read property 'map' of undefined
    at _map (/home/vagrant/node_modules/async/lib/async.js:54:16)
    at _asyncMap (/home/vagrant/node_modules/async/lib/async.js:237:15)
    at Object.map (/home/vagrant/node_modules/async/lib/async.js:219:23)
    at repl:1:7
    at REPLServer.self.eval (repl.js:110:21)
    at repl.js:249:20
    at REPLServer.self.eval (repl.js:122:7)
    at Interface.<anonymous> (repl.js:239:12)
    at Interface.emit (events.js:95:17)
    at Interface._onLine (readline.js:202:10)

Is it possible to do some kind of assertion or something at the beginning of the method to ensure that invalid data is not passed in?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions