rook
05/25/2018, 9:32 PMonError to handle network errors was bad practice. I’m trying to convert one of my calls that is modeled this way, but I’m finding that I lose a little bit of the functionality I relied on in handling network errors the other way.
old way:
someService.someCall()
.subscribe({ response ->
//positive response things
}, { e ->
when(e) {
is HttpException -> //do something
is UnknownHostException -> //do something else
}
new way:
someService.someCall()
.subscribe({ response ->
if(response.isSuccessful()){
//positive response things
} else {
//can no longer check exception types here
}
},{ e ->
//handle really bad stuff here
})