title: Using Node.js, is there some semantic to tell me when code is going to leave the current stack?
body: <p>Right now, it's a mystery to me if my try/catch blocks are going to work at all.  I set them around code, and then, because something in the code was "asynchronous", which appears to be a fancy way of saying forked to another thread/process at the OS level, the try/catch is ignored if it happens in that code.  </p>
  
  <p>I'm fine with that, I just want to know if there's some indication of this?  By convention, I'm given to understand, if a call asks for a callback, it's asych, otherwise it's not. I get why a callback means asych, but I'm afraid that the reverse isn't always true:  THere's nothing stopping me from surrounding a call with a try/catch that gets loaded into a new call stack and also doens't ask for a callback.  This seems really messy to me, and I'd like a little more control over my try/catches than using the default callback that all uncaught exceptions are handled by, if possible.  </p>
  
  <ol>
  <li>Is there a semantic to tell me when code is going to leave the
  current stack?</li>
  </ol>
  
  <p>UPDATE: here is an example:</p>
  
  <pre><code>var UserSchema = new mongoose.Schema({
    email: {type: String, unique: true},
    password: String,
    firstName: String,
    lastName: String,
    created_at: {type: Date, default: Date.now},
    updated_at: Date
  });
  
  
  var User = mongoose.model('User', UserSchema);
  
  var users = [
    {email: 'foo@bar.com', firstName: 'Justin', lastName: 'Jones'},
    {email: 'foo@bar.com', firstName: 'Justin', lastName: 'Jones'}
  ];
  
  
  users.forEach(function(user) {
  
            var newUser = new User(user);
            newUser.save(function(err, obj) {
  
              if (!err) console.log("Saved: ", obj.email);
  
            });
  
  });
  </code></pre>
  
  <p>Given the code above, there's no way to catch an exception inside of save(), as it happens in another call stack.  Is there any way for me to externally know that's what's about to happen when I call save()? </p>
  
  <p>UPDATE:  Everyone telling me to use handlers for this should maybe read <a href="http://debuggable.com/posts/node-js-dealing-with-uncaught-exceptions:4c933d54-1428-443c-928d-4e1ecbdd56cb" rel="nofollow">this</a>?  It's clearly suggesting not to deal with exceptions that aren't caught in their "thread execution", quotes since it only acts like a thread.</p>