阿神2017-04-17 14:54:15
Official example, follow this method to check out err. In addition to stack, you can also look at other contents, such as message, etc., and then locate the error.
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'example.org',
user : 'bob',
password : 'secret'
});
connection.connect(function(err) {
if (err) {
console.error('error connecting: ' + err.stack);
return;
}
console.log('connected as id ' + connection.threadId);
});