0
0

More than 3 years have passed since last update.

RxJavaで連続的なAPI呼び出し後のエラー処理方法

Posted at

RxJavaで連続的にAPIを呼び出して発生するエラーを処理するための方法です。

APIを繰り返し呼び出した場合にエラーが発生する場合、Exception処理を行うためonErrorResumeNextを利用できます。

この関数を利用すると、エラーが発生した時に他のObservableが流れ続けるようにできます。
エラーを返すためにonErrorで処理を分離することもできます。

実例:
repo.getAuth("xxx")
.onErrorResumeNext { Single.error(AuthError("${it.message}")) }
.flatMap { repo.getPayment(it.token) }

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0