Total Complexity | 2 |
Complexity/F | 1 |
Lines of Code | 31 |
Function Count | 2 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | var factory = function (name, parent) { |
||
2 | parent = parent || Error |
||
3 | var error = function (message, parent) { |
||
4 | this.message = message |
||
5 | this.stack = (new Error()).stack |
||
6 | this.parent = parent || null |
||
7 | } |
||
8 | Object.defineProperty(error, 'name', { value: name }) |
||
9 | error.prototype = Object.create(parent.prototype) |
||
10 | error.prototype.name = name |
||
11 | error.prototype.constructor = error |
||
12 | return error |
||
13 | } |
||
14 | |||
15 | var UserError = factory('UserError') |
||
16 | var InternalError = factory('InternalError') |
||
|
|||
17 | |||
18 | module.exports = { |
||
19 | UserError: UserError, |
||
20 | ScenarioError: factory('ScenarioError', UserError), |
||
21 | InvalidInputError: factory('InvalidInputError', UserError), |
||
22 | /** |
||
23 | * @class InternalError |
||
24 | */ |
||
25 | InternalError: InternalError, |
||
26 | /** |
||
27 | * @class IllegalStateError |
||
28 | */ |
||
29 | IllegalStateError: factory('IllegalStateError', InternalError), |
||
30 | UnexpectedError: factory('UnexpectedError', InternalError) |
||
31 | } |
||
32 |