Today I have tried node.js MySQL snippet from a site:
var mysql = require('mysql');
var con = mysql.createConnection({
host: "localhost",
user: "roots",
password: ""
});
con.connect(function(err) {
if (err) throw err;
console.log("Connected!");
con.query("CREATE DATABASE mydb", function (err, result) {
if (err) throw err;
console.log("Database created");
});
});
I needed to learn how to handle MySQL errors because my app needs MySQL. However, later I started app.js file this following error displayed:
![image](https://i.imgur.com/3qm7hmW.png)
Why can not I throw an error?