Error Handling Documentation - adamstallard/vows GitHub Wiki
###Error Handling
Vows detects errors in both topics and vows and keeps track of "errored" tests in the test results.
If you would like errors in a topic to be passed to a vow rather than processed as a test result, give the vow two (or more) parameters--the first will receive an error (or null if there is no error); the second (or additional) will receive its value from the topic.
{
topic: function () {
fs.stat('~/FILE', this.callback);
},
'can be accessed': function (err, stat) {
assert.isNull (err); // We have no error
assert.isObject (stat); // We have a stat object
}
}
The exception to this is if this.callback.multi
is used.
###this.callback
this.callback
assumes two arguments: the first is an error (or null if there is no error), and the second is a value which will be passed on to vows and sub-topics.
If you will be giving this.callback
only one value argument and no error argument, set the option this.callback.errors = false
before using this.callback
.
If you will be giving this.callback
multiple value arguments, but still want Vows to handle errors for you, set this.callback.multi = true
. If your multiple-argument-callback has an initial error argument, also set this.callback.errors = true
. Don't set this.callback.multi = true
if you want to handle your own errors.
See also Thoughts on Error Handling.