I wanted to test my async function querying a table which does not exist. Therefore the error is generated on purpose.
async function getPosts() {
try {
const connection = await dbConnection()
const result = await connection.query('SELECT * FROM x')
await connection.release()
console.log(result)
}
catch(ex) {
throw new Error(ex)
}
}
When I call that function:
UnhandledPromiseRejectionWarning: Error: Error: ER_NO_SUCH_TABLE: Table 'test.x' doesn't exist.
Can you tell me why?