Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RxJava emit multiple errors

Tags:

java

rx-java

The server I'm communicating with has an option to join multiple calls into one. so assuming I'm joining 2..n calls into one call the reponse can retrieve 0..n errors at once. is there a way to emmit multiple errors in one disposable?

like image 803
Ofek Regev Avatar asked Dec 06 '25 11:12

Ofek Regev


1 Answers

According to Reactive Streams contract, there is no way to call onError() several times for single source. When you combining multiple sources into one, that source should also satisfy described contract.

If you need so strange behavior, you can use Observable#onErrorReturn, Observable#onErrorResumeNext and similar operators. Using that operators, you can wrap exceptions in some class (for example, class Result(e: Exception)) and pass it through rx chain.

like image 53
ConstOrVar Avatar answered Dec 08 '25 00:12

ConstOrVar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!