Get Failure keys in bulk operation

Hi I am doing the insert bulk operation.

	List<JsonDocument> success = Collections.synchronizedList(new ArrayList<JsonDocument>());
				.flatMap(document -> connection.getBucket().async().insert(document))
				.doOnNext(doc -> success.add(doc))
				.doOnError(err -> logger.error("Labham -", err))

In the above method, I am able to create successfully list of success in inserting document but is there a way so that i can create a map<key, Throwable> failure; so that for the failed docs i can map them to there whatever exception is thrown by couchbase.

Couchbase - 4.1.0-5005 Community Edition Java. 1.8 and couchbase-Client --> 2.4.3

We do this to track how we do gets that fail. You could do something similar.

        Map<K, CouchbaseOperationResult<T>> results = new HashMap<>(keys.size());

        for (K k : keys) {
            String cbKey = getKeyProvider().getCouchbaseKey(k);
            keyLookups.put(cbKey, k);

        // See:
        List<JsonDocument> foundDocs = Observable
                .compose(o -> o.flatMap(getCouchProvider().getBucket().async()::get))

        for (Document jsonDocument : foundDocs) {
            K key = keyLookups.remove(;
            results.put(key, createEntityResult(jsonDocument));

        for (K keyAddMissing : keyLookups.values()) {
            results.put(keyAddMissing, createEntityResult(null));

        return results;