UNPKG

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