Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

133
Views
How to catch Mysql query errors?

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?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!