All files UndefinedKeyError.js

100% Statements 1/1
100% Branches 0/0
100% Functions 0/0
100% Lines 1/1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39          1x                                                                  
/**
 * Undefined Key error.
 *
 * Most of this code is © 2015 Ben Youngblood <https://github.com/bjyoungblood/es6-error>
 */
module.exports = class UndefinedKeyError extends ReferenceError {
  /* istanbul ignore next */ // because I ripped this from another project
  constructor (message = '') {
    super(message)
 
    // extending Error is weird and does not propagate `message`
    Object.defineProperty(this, 'message', {
      configurable: true,
      enumerable: false,
      value: message,
      writable: true
    })
 
    Object.defineProperty(this, 'name', {
      configurable: true,
      enumerable: false,
      value: this.constructor.name,
      writable: true
    })
 
    if (ReferenceError.hasOwnProperty('captureStackTrace')) {
      ReferenceError.captureStackTrace(this, this.constructor)
      return
    }
 
    Object.defineProperty(this, 'stack', {
      configurable: true,
      enumerable: false,
      value: (new ReferenceError(message)).stack,
      writable: true
    })
  }
}