These are chat archives for ReactiveX/RxJava

4th
Jun 2015
Matt Langston
@mattblang
Jun 04 2015 15:57
I am running two async operations with a FlatMap. I am handling the Throwable if something happens with the HTTP request, but we have also created a system on the server side that will return back a successful response with an error code for the client to handle. I'm trying to figure out what to do in the first call of the FlatMap chain if this server error is returned.
Robert Winkler
@RobWin
Jun 04 2015 16:08
Does it throw a runtimeException? Or do you have to parse the response and check the content?
Matt Langston
@mattblang
Jun 04 2015 16:09
@RobWin Parse the response and check the content. Yeah, the Throwable part I have handled np with an Action0<Throwable>.
@RobWin Just not sure the kosher way to handle the non-throwable error (that I see when content is checked).
Robert Winkler
@RobWin
Jun 04 2015 16:10
Could you decorate the other API and throw an exception if the content has an error code?
To handle all APIs the same?
Matt Langston
@mattblang
Jun 04 2015 16:12
@RobWin That is a really good idea man! I’m using Retrofit, which is a Java library for doing HTTP response / parsing. I could write an interceptor that checks for the error. Heck yes! Thank you. Just for my own knowledge, what would happen if I return null from the first flatMap observable?
@RobWin (I meant HTTP request / response parsing)
@RobWin (Err, that is still ambigious. It does the HTTP call and parses the response, lol)
Robert Winkler
@RobWin
Jun 04 2015 16:14
Yes I know Retrofit :)
Not sure about the null response. You must check JavaDoc.
Do you use Java8?
If yes, have a look at the Try (Error-Handling) Monad of http://javaslang.com
If you need a circuit breaker look at https://github.com/RobWin/circuitbreaker-java8
Its new and not released yet, but I soon release the first Version.
Robert Winkler
@RobWin
Jun 04 2015 16:20
Maybe we move it into javaslang as a new module.
You can decorate any function (supplier or Runnable) with a circuit breaker
Brings some scala flavour to java8