title: Node JS Unhandler Error Event
body: <p>I am a newbie here, i am trying to write a code, which used node's event emitter in it, see the below code,</p>
  
  <pre><code>var EventEmitter = require('events').EventEmitter;
  var errors = require('./errors');
  
  var defaults ={
      default_api_endpoint_v0 : "someapi",
      oauth_c_key: "oauth_consumer_key",
      options_check: ['oauth_consumer_key']
  };
  
  var someapi = function(options){
      this.options = options;
      EventEmitter.call(this);
      if(!this.options)
          this.emit('error',errors.options_not_passed);
          return;
          //return errors.options_not_passed
      if(!this.checkOptions()){
          return errors.options_passed_not_satisfied
      }
  
  };
  
  someapi.prototype = Object.create(EventEmitter.prototype);
  
  someapi.prototype.checkOptions = function(){
      var thatOptions = this.options;
      var bool = false;
      if(typeof thatOptions !== 'object')
        return errors.options_passed_not_satisfied;
      Object.keys(thatOptions).forEach(function(key){
          Object.keys(defaults.options_check).forEach(function(Key){
              if(key === defaults.options_check[Key]){
                  bool = true;
              }
          })
      });
      return bool;
  };
  
  module.exports = someapi
  </code></pre>
  
  <p>and i am invoking it like this below, </p>
  
  <pre><code>var op = new someapi();
  
  op.on('error',function(err){
      console.log("Emitted" + err);
  })
  </code></pre>
  
  <p>But it throws this error, i dunno what i a doing wrong,</p>
  
  <pre><code>events.js:72
          throw er; // Unhandled 'error' event
                ^
  Error: Please pass the options                                      
      at Object.&lt;anonymous&gt; (d:\gitHub\someapi\lib\errors.js:2:26)
      at Module._compile (module.js:456:26)
      at Object.Module._extensions..js (module.js:474:10)
      at Module.load (module.js:356:32)
      at Function.Module._load (module.js:312:12)
      at Module.require (module.js:364:17)
      at require (module.js:380:17)
      at Object.&lt;anonymous&gt; (d:\gitHub\someapi\lib\api.js:2:14)
      at Module._compile (module.js:456:26)
      at Object.Module._extensions..js (module.js:474:10)
  </code></pre>
  
  <p>In tha above error, <strong>Please pass the options is returned by me</strong>, it is located in the errors file, see below, </p>
  
  <pre><code>module.exports = {
      options_not_passed : new Error("Please pass the options"),
      options_passed_not_satisfied : "Please check are you sending all the options_params"
  };
  </code></pre>
  
  <p>Could some one, provide me some inputs what i am doing here wrong???</p>
  
  <p>And to the above, i know i am not passing options object while creating object to the someapi class. i want to know why my error is not getting handled in the "on" event.</p>
  
  <p>P.S Thanks in advance.</p>