1 | 'use strict'
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | function DimensionError (actual, expected, relation) {
|
13 | if (!(this instanceof DimensionError)) {
|
14 | throw new SyntaxError('Constructor must be called with the new operator')
|
15 | }
|
16 |
|
17 | this.actual = actual
|
18 | this.expected = expected
|
19 | this.relation = relation
|
20 |
|
21 | this.message = 'Dimension mismatch (' +
|
22 | (Array.isArray(actual) ? ('[' + actual.join(', ') + ']') : actual) +
|
23 | ' ' + (this.relation || '!=') + ' ' +
|
24 | (Array.isArray(expected) ? ('[' + expected.join(', ') + ']') : expected) +
|
25 | ')'
|
26 |
|
27 | this.stack = (new Error()).stack
|
28 | }
|
29 |
|
30 | DimensionError.prototype = new RangeError()
|
31 | DimensionError.prototype.constructor = RangeError
|
32 | DimensionError.prototype.name = 'DimensionError'
|
33 | DimensionError.prototype.isDimensionError = true
|
34 |
|
35 | module.exports = DimensionError
|