You can't throw inside of async code with callbacks. You must use async error handling:
function makeQuery(callback) {
myDB.query(SQL, object, (err, res) => {
if (err) {
callback(err)
return
}
...
}
}
It's up to the caller to provide a suitable callback function that takes (err, response) or something similar. It's also the responsibility of the caller to intercept, handle, or forward any and all errors.
If you use Promise-driven code you can either use .catch() or async functions with await that will work inside try. Sequelize is a good Promise-driven database driver.
Then you have code that looks like this:
let result = await myDB.query(SQL, object)
Which is obviously a lot cleaner.