0

this is library that i use:

compile 'io.reactivex:rxjava:1.1.5'
compile 'io.reactivex:rxandroid:1.2.0'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
compile 'com.squareup.okhttp3:okhttp:3.0.1'

I read this article but as you can see in comment some error occurred with Throwable.

with new version of retrofit we can easily get status code and message but type is unknown(Resonse). anyway, how can i get response body object with these versions?I want to get the error object.I looking for an adapter for it and the exception.

Siavash Abdoli
  • 1,852
  • 3
  • 22
  • 38
  • does [this](http://stackoverflow.com/questions/33983022/handle-errors-in-retrofit-2-rx) help? – Blackbelt Jun 21 '16 at 07:35
  • @Blackbelt no. it wroks on old version. I see all questions before ask – Siavash Abdoli Jun 21 '16 at 07:38
  • old version of RxJava? – Blackbelt Jun 21 '16 at 07:39
  • maybe you could try the newest version of okhttp (3.3.1) – FreshD Jun 21 '16 at 07:47
  • @Blackbelt everything! retrofit rxjava and okhttp! retrofit have many change with beta version! – Siavash Abdoli Jun 21 '16 at 07:48
  • @FreshD as you can see in the comment of that article and as i check this, it's about retrofit. retrofit have so many changes and differences in method and structure between they versions – Siavash Abdoli Jun 21 '16 at 07:51
  • You want to get the response body when you have error? Or you don't know how to get the response body in general? – daniel.keresztes Jun 21 '16 at 10:18
  • @KERiii yes only when i have error. I want to get response body object when error occurred. if i have not any error i get response in onNext method; I already do this but my problem is error handeling and convert errors to theirs objecs. – Siavash Abdoli Jun 21 '16 at 10:31
  • @SiavashA if your status code is 400 and above, the body is returned in response.errorBody() in onResponse callback. (200-399 is response.body()). Other network, IO exceptions would be caught in onFailure callback. – Emma Jun 22 '16 at 22:14
  • @Emma are you kidding me? there is no onResponse and onFailure callback in retrofit adapter for rxjava. – Siavash Abdoli Jun 23 '16 at 21:23
  • all of people who comment on this post, do not try to solve this problem and do not read everything completely! – Siavash Abdoli Jun 23 '16 at 21:25
  • my bad. this helps http://stackoverflow.com/a/33768184/2956135 ? – Emma Jun 23 '16 at 22:04

0 Answers0