I'm building an application which runs Kue after a file has changed, it triggers a set of jobs and all is good. However I want to be able to purposefully fail a job if something goes wrong.
For example, I request a web page, but if the http.statusCode !== 200 the job should fail and no other job should be processed.
How do I go about that?
You can fail a job via
var kue = require('kue')
, jobs = kue.createQueue();
jobs.process('email', function(job, done) {
var err = new Error('purposely fail job');
job.failed().error(err);
done(err);
});
@drudge please close
This doesn't work.
kue.Job.get(job_id, function (err, job) {
var err = new Error('purposely fail job');
job.failed().error(err);
});
The normal way to fail a job is by calling done @knutole , So you should keep a reference to it
Most helpful comment
You can fail a job via
@drudge please close