Reputation: 1086
Having the following code:
import { SQLite } from 'expo';
const db = SQLite.openDatabase('mydb.db')
db.transaction( tx => {
tx.executeSql('insert into invalidTable values (?,?)', [1,2], null, (transact, err) => {
//I can't find error description in the objects below
console.log({transact, err})
})
})
How can I get the sqlite error message, to determine what exactly was the cause of this error (in this case, an invalid table)?
The API documentation says my error function "Takes two parameters: the transaction itself, and the error object", but I couldn't find the error description in none of these.
I did a snack simulating this scenario.
Upvotes: 12
Views: 2701
Reputation: 3467
This logs the errors for me
import { SQLite } from 'expo';
const db = SQLite.openDatabase('mydb.db')
db.transaction(tx => {
tx.executeSql(sql, params, (_, { rows }) => {
console.log(rows._array)
}, (t, error) => {
console.log(error);
})
})
Upvotes: 8