I am using Retrofit 2.6.3 .
I can directly return data model now with Retrofit:
interface WikiApiService {
// Here declare that the function returns Observable<Student>
@GET("student/")
fun getStudent(@Query("id") sid: Int): Observable<Student>
companion object {
fun create(): StudentApiService {
val retrofit = Retrofit.Builder()
.addConverterFactory(GsonConverterFactory.create())
.baseUrl("https://foo.bar.com/")
.build()
return retrofit.create(StudentApiService::class.java)
}
}
}
Then I can call above fun getStudent(@Query("id") sid: Int): Observable<Student>
in UI layer to get an observable data.
All works fine to me & this is concise code, but now I get confused, how can I do response error handling now? Could someone please guide me?