如何使用Throwable
但附加请求返回的正文中的信息?
Throwable
,它接受一个Mono / Flux对象,因此抛出的错误会等待正文被占用?import org.springframework.web.reactive.function.client.WebClient;
private someMethod() {
webClient.get().retrieve().onStatus(HttpStatus::isError, this::errorHandler)
}
)以下示例方案:
private Mono<? extends Throwable> errorHandler(ClientResponse cr) {
Mono<String> body = cr.body(BodyExtractors.toMono(String.class));
...<do something here>...
return Mono.error(new WhateverException());
}
UICollectionView
由于
答案 0 :(得分:2)
return body.flatMap(str -> Mono.error(new WhateverException(str)));