title: Nodejs throw exception
body: <p>I'm working on Nodejs service-side application, my case is that i want to return the throw an exception to the caller(who did call the function), i did two cases, one outside the callback, and the another inside the callback, also the parent has try catch blocks.</p>
  
  <p>concept :
   throw(Business function)-->throw (Business function) -->try &amp; catch</p>
  
  <p>Outside the callback is working correctly.
  Inside the callback didn't return the exception to the parent.</p>
  
  <p>I want to to this scenario,because I'm looking to throw an exception to the parent and stop completion the functions, and this's exist in Java, C++, C and .NET.</p>
  
  <p>So why this scenario is not working with me ?!</p>
  
  <p>My example here with 2 different cases :</p>
  
  <pre><code>FactoryController.prototype.create = function (callback) {
      //The throw is working, and the exception is returned.
      throw new Error('An error occurred'); //outside callback 
      try {
          this.check(function (check_result) {
              callback(check_result);
          });
      } catch (ex) {
          throw new Error(ex.toString());
      }
  }
  
  FactoryController.prototype.create = function (callback) {
      try {
          this.check(function (check_result) {
              //The throw is not working on this case to return the exception to the caller(parent)
              throw new Error('An error occurred'); //inside callback 
          });
      } catch (ex) {
          throw new Error(ex.toString());
      }
  }
  </code></pre>