title: Rethrow non-MySQL errors Node.js
body: <p>Hi the code below loads a single field from a mysql database, but when it gets to the point <strong>result[0].IdUtente</strong> the error below is generated. How do I solve it?</p>
  
  <p><strong>ERROR:</strong></p>
  
  <pre><code> throw err; // Rethrow non-MySQL errors
          ^
  
  TypeError: Cannot read property 'IdUtente' of undefined
  </code></pre>
  
  <p><strong>CODE:</strong></p>
  
  <pre><code>var query = "SELECT IdUtente FROM Utente WHERE Username = " + sql.escape(Username) + " and Password=MD5(" + sql.escape(Password) + ") and Tipo!='Risorsa' ";
  var ret=DbConfig.query(query, function (err, result) {
      if (err) {
          console.log("Errore login: " + err);
      }
      else {
          console.log(result[0].IdUtente);
          IdUtente = result[0].IdUtente;
  
      }
  
  });
  </code></pre>