I am trying to execute a series of functions, each passing the callback to the next. Right now it looks like this (excuse any minor errors, I am rewriting it as I post!):
function func1(callback) {
callback(null, "stuff");
}
function func2(input, callback) {
callback(null, "foo" + input);
}
async.waterfall([func1, func2], function(err, result) {
sys.puts(result);
});
My first question is that I'm not sure how to start this function gracefully, since it can't take an input. I'm going to eventually wrap that one in a local function, but it still makes me slightly uneasy.
Secondly, while this works, I have no idea how the "err" argument plays into this. If I try to insert it into the list of arguments, it breaks in various ways. I'd like to be able to catch an error in any function individually - or is this needed, since I have an error on the last callback which is passed down?