assert error

This commit is contained in:
ferricles 2022-06-24 21:01:54 -07:00
parent 17311ff3b1
commit 61dfe2de65

View file

@ -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;
}
}