Closed JadenSWang closed 2 years ago
Can you give me some example code that causes the issue?
`import { initializePool } from "./init.db";
export async function createUser(user_id: String) { const connectionPool = await initializePool()
const res = await connectionPool.query('CALL prodInitializeNewUser(?)', [user_id]);
return res;
}`
The prodInitializeNewUser procedure just signals an error.
And I break down the result with:
const [data, fields, query] = res
Am I misunderstanding something here?
It should be throwing any errors, but it won't be in res
, because it'll reject the promise. As you're using await
you want to do something like this with try/catch.
import { initializePool } from "./init.db";
export async function createUser(user_id: String) {
const connectionPool = await initializePool()
try {
const res = await connectionPool.query('CALL prodInitializeNewUser(?)', [user_id]);
return res;
} catch (e) {
console.log(e)
}
}
Perhaps there's something wrong with my procedure then, I'll take a look, thanks!
The title says it all and perhaps I'm misunderstanding the return of the query function but how do I catch and handle the errors thrown my the server?