LearnBoost/kue — Issue #89: Job 'failure' event before error is saved
Author: kainosnoema
Created: 2011-12-09 19:23:49+00:00
State: open

I'd like to be able to hook onto the Job 'failure' event and do some job-specific handling of the error that caused the failure, but the event is being emitted [before the error is set on the job](https://github.com/LearnBoost/kue/blob/master/lib/queue/worker.js#L92-93). Even though these events are going through Redis pub/sub, switching the order seems to solve the problem:

```` js
...
job.error(err).failed();
events.emit(job.id, 'failed');
...
````

If there's no other reason why this fix would be a problem, I'd be happy to submit a pull-request.