@@ -390,7 +390,7 @@ public <T> Flux<T> createFlux(ReactiveDatabaseCallback<T> callback) {
390
390
391
391
Assert .notNull (callback , "ReactiveDatabaseCallback must not be null!" );
392
392
393
- return Flux .defer (() -> callback .doInDB (getMongoDatabase ())).onErrorResumeWith ( translateFluxException ());
393
+ return Flux .defer (() -> callback .doInDB (getMongoDatabase ())).onErrorMap ( translateException ());
394
394
}
395
395
396
396
/**
@@ -404,7 +404,7 @@ public <T> Mono<T> createMono(final ReactiveDatabaseCallback<T> callback) {
404
404
405
405
Assert .notNull (callback , "ReactiveDatabaseCallback must not be null!" );
406
406
407
- return Mono .defer (() -> Mono .from (callback .doInDB (getMongoDatabase ()))).otherwise ( translateMonoException ());
407
+ return Mono .defer (() -> Mono .from (callback .doInDB (getMongoDatabase ()))).onErrorMap ( translateException ());
408
408
}
409
409
410
410
/**
@@ -422,7 +422,7 @@ public <T> Flux<T> createFlux(String collectionName, ReactiveCollectionCallback<
422
422
Mono <MongoCollection <Document >> collectionPublisher = Mono
423
423
.fromCallable (() -> getAndPrepareCollection (getMongoDatabase (), collectionName ));
424
424
425
- return collectionPublisher .flatMapMany (callback ::doInCollection ).onErrorResumeWith ( translateFluxException ());
425
+ return collectionPublisher .flatMapMany (callback ::doInCollection ).onErrorMap ( translateException ());
426
426
}
427
427
428
428
/**
@@ -442,7 +442,7 @@ public <T> Mono<T> createMono(String collectionName, ReactiveCollectionCallback<
442
442
.fromCallable (() -> getAndPrepareCollection (getMongoDatabase (), collectionName ));
443
443
444
444
return collectionPublisher .flatMap (collection -> Mono .from (callback .doInCollection (collection )))
445
- .otherwise ( translateMonoException ());
445
+ .onErrorMap ( translateException ());
446
446
}
447
447
448
448
/* (non-Javadoc)
@@ -1850,36 +1850,19 @@ private <T> T execute(MongoDatabaseCallback<T> action) {
1850
1850
}
1851
1851
1852
1852
/**
1853
- * Exception translation {@link Function} intended for {@link Flux#onErrorResumeWith (Function)} usage.
1853
+ * Exception translation {@link Function} intended for {@link Flux#mapError (Function)} } usage.
1854
1854
*
1855
1855
* @return the exception translation {@link Function}
1856
1856
*/
1857
- private < T > Function <Throwable , Publisher <? extends T >> translateFluxException () {
1857
+ private Function <Throwable , Throwable > translateException () {
1858
1858
1859
1859
return throwable -> {
1860
1860
1861
1861
if (throwable instanceof RuntimeException ) {
1862
- return Flux . error ( potentiallyConvertRuntimeException ((RuntimeException ) throwable , exceptionTranslator ) );
1862
+ return potentiallyConvertRuntimeException ((RuntimeException ) throwable , exceptionTranslator );
1863
1863
}
1864
1864
1865
- return Flux .error (throwable );
1866
- };
1867
- }
1868
-
1869
- /**
1870
- * Exception translation {@link Function} intended for {@link Mono#otherwise(Function)} usage.
1871
- *
1872
- * @return the exception translation {@link Function}
1873
- */
1874
- private <T > Function <Throwable , Mono <? extends T >> translateMonoException () {
1875
-
1876
- return throwable -> {
1877
-
1878
- if (throwable instanceof RuntimeException ) {
1879
- return Mono .error (potentiallyConvertRuntimeException ((RuntimeException ) throwable , exceptionTranslator ));
1880
- }
1881
-
1882
- return Mono .error (throwable );
1865
+ return throwable ;
1883
1866
};
1884
1867
}
1885
1868
0 commit comments