From what I understand, if the document does not exist, I get the result back as an error.
But I dont see that .doOnError gets called. It always throw the exception instead
Am I doing something wrong here?
The code is below:
public static String readbucket(final String documnetId) {
if (couchbase == null) {
couchbase = new Couchbase();
}
final Bucket bucket = couchbase.getNGTVEHDATABucket();
JsonDocument result =null;
try {
result = (JsonDocument) bucket
.async()
.get("bogusid")
.doOnError(new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
logger.debug("Error reading the doucment : " + throwable.getLocalizedMessage());
}
})
.timeout(1, TimeUnit.SECONDS) // don't forget the timeout
.toBlocking()
.single();
} catch (Exception e) {
// when the item does not exist, it always come here.
logger.info("READ CB Exception :" + e.getLocalizedMessage());
}
return result.content().toString();
}