Skip to content

Add optional error handler to queues#1170

Merged
aearly merged 3 commits intocaolan:masterfrom
jnordberg:queue-error
May 31, 2016
Merged

Add optional error handler to queues#1170
aearly merged 3 commits intocaolan:masterfrom
jnordberg:queue-error

Conversation

@jnordberg
Copy link
Copy Markdown
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'});

jnordberg added 2 commits May 29, 2016 12:06
With the signature `function(error, task){}`
@aearly
Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

Sure, to the README right?

@megawac
Copy link
Copy Markdown
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