让我们说我有一个通量,其中一个元素引发错误。
Flux.just("aeiou","aeio").map(x -> {
if(!x.endsWith("u")){throws Exception;}
return x;})
.onErrorReturn(/*This only accepts a new element*/)
.map(x -> x+";")
.subscribe();
Flux.just("aeiou","aeio").map(x -> {
if(!x.endsWith("u")){throws Exception;}
return x;})
.onErrorResume(/*This doesn't do the next steps*/)
.map(x -> x+";")
.subscribe();
我想要这样的东西
Flux.just("aeiou","aeio").map(x -> {
if(!x.endsWith("u")){throws Exception;}
return x;})
.onErrorReturn(x -> x + "u")
.map(x -> x+";")
.subscribe();
文档似乎有误 http://projectreactor.io/docs/core/release/reference/#_fallback_method
Flux.just("key1", "key2")
.flatMap(k -> callExternalService(k))
.onErrorResume(e -> getFromCache(k)); //k not resolved here