Comparing version 0.5.1 to 0.5.2
0.5.2 / 2014-01-06 | ||
================== | ||
* Added ability for job.fail to take an error | ||
0.5.1 / 2013-01-04 (Backwards compatible!) | ||
@@ -3,0 +8,0 @@ ================== |
@@ -81,2 +81,5 @@ var humanInterval = require('human-interval'), | ||
Job.prototype.fail = function(reason) { | ||
if(reason instanceof Error) { | ||
reason = reason.message; | ||
} | ||
this.attrs.failReason = reason; | ||
@@ -99,3 +102,3 @@ this.attrs.failedAt = new Date(); | ||
if(err){ | ||
self.fail(err.message); | ||
self.fail(err); | ||
agenda.emit('fail', err, self); | ||
@@ -102,0 +105,0 @@ agenda.emit('fail:' + self.attrs.name, err, self); |
{ | ||
"name": "agenda", | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"description": "Light weight job scheduler for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -336,4 +336,9 @@ # Agenda | ||
Optionally, `reason` can be an error, in which case `job.attrs.failReason` will | ||
be set to `error.message` | ||
```js | ||
job.fail('insuficient disk space'); | ||
// or | ||
job.fail(new Error('insufficient disk space')); | ||
job.save(); | ||
@@ -340,0 +345,0 @@ ``` |
@@ -308,6 +308,10 @@ var mongoCfg = 'localhost:27017/agenda-test', | ||
var job = new Job(); | ||
it('sets the fail reason', function() { | ||
it('takes a string', function() { | ||
job.fail('test'); | ||
expect(job.attrs.failReason).to.be('test'); | ||
}); | ||
it('takes an error object', function() { | ||
job.fail(new Error('test')); | ||
expect(job.attrs.failReason).to.be('test'); | ||
}); | ||
it('sets the failedAt time', function() { | ||
@@ -314,0 +318,0 @@ job.fail('test'); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37930
742
439