1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.IndexError = IndexError;
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | function IndexError(index, min, max) {
|
19 | if (!(this instanceof IndexError)) {
|
20 | throw new SyntaxError('Constructor must be called with the new operator');
|
21 | }
|
22 |
|
23 | this.index = index;
|
24 |
|
25 | if (arguments.length < 3) {
|
26 | this.min = 0;
|
27 | this.max = min;
|
28 | } else {
|
29 | this.min = min;
|
30 | this.max = max;
|
31 | }
|
32 |
|
33 | if (this.min !== undefined && this.index < this.min) {
|
34 | this.message = 'Index out of range (' + this.index + ' < ' + this.min + ')';
|
35 | } else if (this.max !== undefined && this.index >= this.max) {
|
36 | this.message = 'Index out of range (' + this.index + ' > ' + (this.max - 1) + ')';
|
37 | } else {
|
38 | this.message = 'Index out of range (' + this.index + ')';
|
39 | }
|
40 |
|
41 | this.stack = new Error().stack;
|
42 | }
|
43 |
|
44 | IndexError.prototype = new RangeError();
|
45 | IndexError.prototype.constructor = RangeError;
|
46 | IndexError.prototype.name = 'IndexError';
|
47 | IndexError.prototype.isIndexError = true; |
\ | No newline at end of file |