There is a feature on the CouchbaseTemplate class in Spring Data Couchbase to set how exceptions are handled on writes, using the setWriteResultChecking method.
There doesn't seem to be any information on this in the documentation.
If you dig into the source code, the default setting is NONE. This means that exceptions get logged but don't get passed back up to your calling code.
Please does anyone know why this is the default behaviour? Wouldn't it make more sense to use EXCEPTION, so at least your calling code knows that something has gone wrong?
I've not got a lot of experience with Spring data for Couchbase, or indeed Couchbase, so I feel like I'm missing a fundamental point here.
Thanks.
For future reference, this is how I set the write checking to EXCEPTION:
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.couchbase.config.AbstractCouchbaseConfiguration;
import org.springframework.data.couchbase.config.BeanNames;
import org.springframework.data.couchbase.core.CouchbaseTemplate;
import org.springframework.data.couchbase.core.WriteResultChecking;
@Configuration
public class CouchbaseConfig extends AbstractCouchbaseConfiguration {
@Override
@Bean(name = BeanNames.COUCHBASE_TEMPLATE)
public CouchbaseTemplate couchbaseTemplate() throws Exception {
CouchbaseTemplate couchbaseTemplate = super.couchbaseTemplate();
couchbaseTemplate.setWriteResultChecking(WriteResultChecking.EXCEPTION);
return couchbaseTemplate;
}
}
I didn't include this as an answer, because it isn't answering the question. The quesstion was about why NONE is the default.