private Mono<? extends String> translateException(Throwable e, IndexDefinitionHolder indexDefinition) { Mono<IndexInfo> existingIndex = fetchIndexInformation(indexDefinition); Mono<String> defaultError = Mono.error(new DataIntegrityViolationException( String.format("Cannot create index for '%s' in collection '%s' with keys '%s' and options '%s'.", indexDefinition.getPath(), indexDefinition.getCollection(), indexDefinition.getIndexKeys(), indexDefinition.getIndexOptions()), e.getCause())); return existingIndex.flatMap(it -> { return Mono.<String> error(new DataIntegrityViolationException( String.format("Index already defined as '%s'.", indexDefinition.getPath()), e.getCause())); }).switchIfEmpty(defaultError); }
private Mono<? extends String> translateException(Throwable e, IndexDefinitionHolder indexDefinition) { Mono<IndexInfo> existingIndex = fetchIndexInformation(indexDefinition); Mono<String> defaultError = Mono.error(new DataIntegrityViolationException( String.format("Cannot create index for '%s' in collection '%s' with keys '%s' and options '%s'.", indexDefinition.getPath(), indexDefinition.getCollection(), indexDefinition.getIndexKeys(), indexDefinition.getIndexOptions()), e.getCause())); return existingIndex.flatMap(it -> { return Mono.<String> error(new DataIntegrityViolationException( String.format("Index already defined as '%s'.", indexDefinition.getPath()), e.getCause())); }).switchIfEmpty(defaultError); }