Code coverage report for lib/formatted-error.js

Statements: 100% (18 / 18)      Branches: 100% (4 / 4)      Functions: 100% (1 / 1)      Lines: 100% (18 / 18)      Ignored: none     

All files » lib/ » formatted-error.js
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  1 1 1 1   1   1     6 6 3     6 3     3   3 3   3 3   3       1  
 
const util = require('util')
const format = util.format
const inherits = util.inherits
const filter = require('filter-stack')
 
module.exports = HaikuError
 
function HaikuError(args) {
  // http://ejohn.org/blog/simple-class-instantiation/
  // http://www.devthought.com/2011/12/22/a-string-is-not-an-error/
  http://npmawesome.com/posts/2014-08-11-verror/?utm_source=nodeweekly&utm_medium=email
  if (arguments.length > 1) {
    args = Array.prototype.slice.call(arguments)
  }
 
  if (! (this instanceof HaikuError)) {
    return new HaikuError(args)
  }
 
  var err = this
 
  Error.call(err)
  Error.captureStackTrace(err, HaikuError)
 
  err.name = err.constructor.name
  err.message = format.apply(null, args)
 
  err.stack = filter(err, [ 'haiku/lib/formatted-error' ]).stack
 
}
 
inherits(HaikuError, Error)