emit-error.js 395 B

12345678910111213
  1. 'use strict';
  2. var ensureError = require('es5-ext/error/valid-error')
  3. , ensureObject = require('es5-ext/object/valid-object')
  4. , hasOwnProperty = Object.prototype.hasOwnProperty;
  5. module.exports = function (err) {
  6. (ensureObject(this) && ensureError(err));
  7. if (!hasOwnProperty.call(ensureObject(this), '__ee__')) throw err;
  8. if (!this.__ee__.error) throw err;
  9. this.emit('error', err);
  10. };