mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-25 15:07:57 +00:00
27 lines
924 B
JavaScript
27 lines
924 B
JavaScript
/**
|
|
* Create a syntax error with the message:
|
|
* 'Wrong number of arguments in function <fn> (<count> provided, <min>-<max> expected)'
|
|
* @param {String} name Function name
|
|
* @param {Number} count Actual argument count
|
|
* @param {Number} min Minimum required argument count
|
|
* @param {Number} [max] Maximum required argument count
|
|
* @extends Error
|
|
*/
|
|
function ArgumentsError(name, count, min, max) {
|
|
if (!(this instanceof ArgumentsError)) {
|
|
throw new SyntaxError('Constructor must be called with the new operator');
|
|
}
|
|
|
|
this.message = 'Wrong number of arguments in function ' + name +
|
|
' (' + count + ' provided, ' +
|
|
min + ((max != undefined) ? ('-' + max) : '') + ' expected)';
|
|
|
|
this.stack = (new Error()).stack;
|
|
}
|
|
|
|
ArgumentsError.prototype = new Error();
|
|
ArgumentsError.prototype.constructor = Error;
|
|
ArgumentsError.prototype.name = 'ArgumentsError';
|
|
|
|
module.exports = ArgumentsError;
|