assert error
This commit is contained in:
parent
17311ff3b1
commit
61dfe2de65
1 changed files with 13 additions and 0 deletions
13
js/utils.js
13
js/utils.js
|
@ -510,3 +510,16 @@ function assert_null(arg, msg) {
|
|||
}
|
||||
}
|
||||
|
||||
/** Asserts that there is an error when a callback function is run.
|
||||
*
|
||||
* @param {Function} func_binding - a function binding to run. Can be passed in with func.bind(null, arg1, ..., argn)
|
||||
* @param {String} msg - the error message to throw.
|
||||
*/
|
||||
function assert_error(func_binding, msg) {
|
||||
try {
|
||||
func_binding();
|
||||
console.trace(msg ? msg : "Function didn't throw an error.");
|
||||
} catch (err) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue