Skip to content

Commit 311eb0e

Browse files
committed
Add error handling similar to other methods (this was causing the error to be swallowed).
1 parent 2e6a0f2 commit 311eb0e

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/core.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -733,14 +733,18 @@ function SqlPouch(opts: OpenDatabaseOptions, cb: (err: any) => void) {
733733

734734
api._getLocal = (id: string, callback: (err: any, doc?: any) => void) => {
735735
readTransaction(async (tx: Transaction) => {
736-
const sql = 'SELECT json, rev FROM ' + LOCAL_STORE + ' WHERE id=?'
737-
const res = await tx.executeAsync(sql, [id])
738-
if (res.rows?.length) {
739-
const item = res.rows.item(0)
740-
const doc = unstringifyDoc(item.json, id, item.rev)
741-
callback(null, doc)
742-
} else {
743-
callback(createError(MISSING_DOC))
736+
try {
737+
const sql = 'SELECT json, rev FROM ' + LOCAL_STORE + ' WHERE id=?'
738+
const res = await tx.executeAsync(sql, [id])
739+
if (res.rows?.length) {
740+
const item = res.rows.item(0)
741+
const doc = unstringifyDoc(item.json, id, item.rev)
742+
callback(null, doc)
743+
} else {
744+
callback(createError(MISSING_DOC))
745+
}
746+
} catch (e: any) {
747+
handleSQLiteError(e, callback)
744748
}
745749
})
746750
}

0 commit comments

Comments
 (0)