ArgumentsError.js (1129B)
1 "use strict"; 2 3 Object.defineProperty(exports, "__esModule", { 4 value: true 5 }); 6 exports.ArgumentsError = ArgumentsError; 7 8 /** 9 * Create a syntax error with the message: 10 * 'Wrong number of arguments in function <fn> (<count> provided, <min>-<max> expected)' 11 * @param {string} fn Function name 12 * @param {number} count Actual argument count 13 * @param {number} min Minimum required argument count 14 * @param {number} [max] Maximum required argument count 15 * @extends Error 16 */ 17 function ArgumentsError(fn, count, min, max) { 18 if (!(this instanceof ArgumentsError)) { 19 throw new SyntaxError('Constructor must be called with the new operator'); 20 } 21 22 this.fn = fn; 23 this.count = count; 24 this.min = min; 25 this.max = max; 26 this.message = 'Wrong number of arguments in function ' + fn + ' (' + count + ' provided, ' + min + (max !== undefined && max !== null ? '-' + max : '') + ' expected)'; 27 this.stack = new Error().stack; 28 } 29 30 ArgumentsError.prototype = new Error(); 31 ArgumentsError.prototype.constructor = Error; 32 ArgumentsError.prototype.name = 'ArgumentsError'; 33 ArgumentsError.prototype.isArgumentsError = true;