/**
* Mark the current job as having failed
*
* @param \Exception $e
*/
public function fail(\Exception $e)
{
$this->stopped();
$this->setStatus(Job::STATUS_FAILED, $e);
// For the failed jobs we store a lot more data for debugging
$packet = $this->getPacket();
$failed_payload = array_merge(json_decode($this->payload, true), array('worker' => $packet['worker'], 'started' => $packet['started'], 'finished' => $packet['finished'], 'output' => $packet['output'], 'exception' => (array) json_decode($packet['exception'], true)));
$this->redis->zadd(Queue::redisKey($this->queue, 'failed'), time(), json_encode($failed_payload));
Stats::incr('failed', 1);
Stats::incr('failed', 1, Queue::redisKey($this->queue, 'stats'));
Event::fire(Event::JOB_FAILURE, array($this, $e));
}