How to implement DATABASE TRANSACTIONS in couchbase lite?

Admittedly, this is difficult, since the Runnable does not permit throwing checked exceptions. The lambda passed to the inBatch method has to look something like this:

try {
   doStuffMightThrow()
   doMoreStuffMightThrow()
}
catch (SomeException | SomeOtherException e) {
   throw new RuntimeException("batch action failed", e);
}

… which is silly. As soon as we are allowed to make some changes to the API, I will fix this.

1 Like