1 | 'use strict'
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | function ArgumentsError (fn, count, min, max) {
|
13 | if (!(this instanceof ArgumentsError)) {
|
14 | throw new SyntaxError('Constructor must be called with the new operator')
|
15 | }
|
16 |
|
17 | this.fn = fn
|
18 | this.count = count
|
19 | this.min = min
|
20 | this.max = max
|
21 |
|
22 | this.message = 'Wrong number of arguments in function ' + fn +
|
23 | ' (' + count + ' provided, ' +
|
24 | min + ((max !== undefined && max !== null) ? ('-' + max) : '') + ' expected)'
|
25 |
|
26 | this.stack = (new Error()).stack
|
27 | }
|
28 |
|
29 | ArgumentsError.prototype = new Error()
|
30 | ArgumentsError.prototype.constructor = Error
|
31 | ArgumentsError.prototype.name = 'ArgumentsError'
|
32 | ArgumentsError.prototype.isArgumentsError = true
|
33 |
|
34 | module.exports = ArgumentsError
|