title: How to handle node.js errors properly - the standart way
body: <p><strong>For about developer errors that are made by mistake or undefined or something else that can crash the whole app:</strong></p>
  
  <p>Should I use this:</p>
  
  <pre><code>var domain = require('domain');
  var d = domain.create();
  d.on('error', function(err) {
    console.error(err);
  });
  
  d.run(function() {
    if (someom.sadjaslkd.asdasd=="yes") console.log("Yes");
    // run more other things in the safe area
  });
  </code></pre>
  
  <p>Purposely <code>someom.sadjaslkd.asdasd</code> is undefined.</p>
  
  <p>OR should I use this:</p>
  
  <pre><code>try {
   if (someom.sadjaslkd.asdasd=="yes") console.log("Yes");
   // run more other things in the safe area
  } catch(err) {
   // handle the error safely
  }
  </code></pre>
  
  <p><strong>For about operation errors that are made not by mistake but due to client's faults:</strong></p>
  
  <p>Should I use this:</p>
  
  <pre><code>if (somethingWorng) res.status(400).json({status: "400", error: "Some custom error message to the user"});
  </code></pre>
  
  <p>OR maybe I should pass the error like this:</p>
  
  <pre><code>if (somethingWorng) throw "Some custom error message to the user";
  </code></pre>
  
  <p>OR maybe</p>
  
  <pre><code>if (somethingWorng) throw new Error("Some custom error message to the user");
  </code></pre>
  
  <p>Really there tons of ways to make this work. Is there a quick easy, readable, best practice?</p>