lib/Error/index.js   A
last analyzed

Complexity

Total Complexity 2
Complexity/F 1

Size

Lines of Code 31
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
wmc 2
nc 1
mnd 0
bc 2
fnc 2
dl 0
loc 31
rs 10
bpm 1
cpm 1
noi 1
c 1
b 0
f 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')
0 ignored issues
show
Comprehensibility introduced by
You are shadowing the built-in type InternalError. This makes code hard to read, consider using a different name.
Loading history...
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