Skip to content

Commit 327905b

Browse files
Handle exceptions in Box._inReadTransaction
1 parent fcaf2a2 commit 327905b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

objectbox/lib/src/box.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,12 @@ class Box<T> {
272272
_inReadTransaction(fn) {
273273
Pointer<Void> txn = bindings.obx_txn_read(_store.ptr);
274274
checkObxPtr(txn, "failed to created transaction");
275-
var ret = fn();
276-
checkObx(bindings.obx_txn_close(txn));
275+
var ret;
276+
try {
277+
ret = fn();
278+
} finally {
279+
checkObx(bindings.obx_txn_close(txn));
280+
}
277281
return ret;
278282
}
279283

0 commit comments

Comments
 (0)