I have this:
const connector = mysql.createPool({
connectionLimit: 20,
host: "127.0.0.1",
database: "todo",
user: "root",
password: "password",
});
executes :
const execute = async (query: string) => {
try {
const rows = await connector.query(query);
console.log("done", rows);
return rows;
} catch (err) {
// ERROR NEVER HERE --- WHY?
console.log("DB ERROR => " + err);
return err;
}
};
export default execute;
calling:
execute("INSERT INTO tablename (column1) VALUES('hello')")
I had a typo when doing an INSERT and could not understand what was going wrong before I console logged the flow. I expected that query would throw the error to my catch but for some reason it never did, why?