How to catch ER_BAD_FIELD_ERROR
lz000 opened this issue · 2 comments
lz000 commented
I have this code
const connection = mysql.createConnection(dbConfig);
connection.query(
'INSERT INTO ...',
[...],
(e) => {
if (e) {
console.log(e)
};
}
);
When ER_BAD_FIELD_ERROR happens, It is not handled by the callback, thus the if (e)
conditional is not invoked. Instead it causes the program to terminate with uncaught error. I also tried adding try catch
around the connection.query
but same issue. Is there a way to catch this error so that program will not stop?
dougwilson commented
Hi, very sorry that happened. Can you provide a complete reproduction result? A quick try did work as you expected, but there is so little information provided so far, for example the query, parameters, etc.
lz000 commented
sorry my bad, it is actually a different error causing the program to stop