title: Nodejs error handling with domains and socket.io
body: <p>I'm just starting using domains in nodejs for error management.</p>
  
  <p>There's something I cant understand when I use them with socket.io.</p>
  
  <p>That's my example code:</p>
  
  <pre><code>io.sockets.on('connection', function cb1(socket){
      socket.on('event', function cb2(data){
      });
  });
  </code></pre>
  
  <p>I started putting all my code in the "run" method</p>
  
  <pre><code>domain.run(function(){
      io.sockets.on('connection', function cb1(socket){
          socket.on('event', function cb2(data){
          });
      });
  });
  </code></pre>
  
  <p>But if an error happens in cb1 or cb2 it is not handled!</p>
  
  <p>Then I used the bind methon on che cb1</p>
  
  <pre><code>domain.run(function(){
      io.sockets.on('connection', domain.bind(function cb1(socket){
          socket.on('event', function cb2(data){
          });
      }));
  });
  </code></pre>
  
  <p>But if an error happens in cb2 it is not handled!</p>
  
  <p>My question is:
  do I have to put a single "bind" on every callback? In the server and in the required files?</p>
  
  <p>When I started studied the domains all the tutorials define them like the best solution to handle your errors in one single point!</p>
  
  <p>Am I missing something?</p>