Ofek Regev
Ofek Regev

Reputation: 502

RxJava emit multiple errors

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?

Upvotes: 3

Views: 587

Answers (1)

ConstOrVar
ConstOrVar

Reputation: 2085

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.

Upvotes: 2

Related Questions