我想测试查询不存在的表的异步功能。因此,该错误是有意产生的。
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)
}
}
Run Code Online (Sandbox Code Playgroud)
当我调用该函数时:
UnhandledPromiseRejectionWarning:错误:错误:ER_NO_SUCH_TABLE:表'test.x'不存在。
你能告诉我为什么吗?