mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
Add assert.ifError
This commit is contained in:
@@ -2546,6 +2546,9 @@ Expects `block` to throw an error.
|
||||
|
||||
Expects `block` not to throw an error.
|
||||
|
||||
### assert.ifError(value)
|
||||
|
||||
Tests if value is not a false value, throws if it is a true value. Useful when testing the first argument, `error` in callbacks.
|
||||
|
||||
## Path
|
||||
|
||||
|
||||
@@ -284,3 +284,4 @@ assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) {
|
||||
_throws.apply(this, [false].concat(pSlice.call(arguments)));
|
||||
};
|
||||
|
||||
assert.ifError = function (err) { if (err) {throw err;}};
|
||||
|
||||
@@ -154,3 +154,6 @@ try {
|
||||
}
|
||||
assert.equal(true,threw,'a.doesNotThrow is not catching type matching errors');
|
||||
|
||||
assert.throws(function () {assert.ifError(new Error('test error'))});
|
||||
assert.doesNotThrow(function(){assert.ifError(null)});
|
||||
assert.doesNotThrow(function(){assert.ifError()});
|
||||
|
||||
Reference in New Issue
Block a user