Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional error handler to queues #1170

Merged
merged 3 commits into from
May 31, 2016
Merged

Conversation

jnordberg
Copy link
Contributor

Allowing you to implement things like error logging and task retries more easily, like so:

var q = async.queue(function(task, callback) {
    console.log('Oops.');
    callback(new Error('I fail every time'));
});

q.error = function(error, task) {
    if (task.retries == null) task.retries = 0;
    task.retries++;
    if (task.retries < 3) {
        q.push(task);
    } else {
        console.log('This isnt working...');
    }
};

q.push({foo: 'bar'});

With the signature `function(error, task){}`
@aearly
Copy link
Collaborator

aearly commented May 31, 2016

Looks good. This feature has been requested a few times before.

Can you add a note to the doc block about the feature?

@jnordberg
Copy link
Contributor Author

Sure, to the README right?

@megawac
Copy link
Collaborator

megawac commented May 31, 2016

@jnordberg to the jsdoc above the function preferably. The readme docs are on their way out

@aearly aearly merged commit 4c78fc2 into caolan:master May 31, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants