save-stack.js 349 B

12345678910111213141516
  1. 'use strict'
  2. var inherits = require('inherits')
  3. module.exports = SaveStack
  4. function SaveStack (fn) {
  5. Error.call(this)
  6. Error.captureStackTrace(this, fn || SaveStack)
  7. }
  8. inherits(SaveStack, Error)
  9. SaveStack.prototype.completeWith = function (er) {
  10. this['__' + 'proto' + '__'] = er
  11. this.stack = this.stack + '\n\n' + er.stack
  12. return this
  13. }