https://kotlinlang.org logo
Title
k

Kevin Janvier Chinabalire

12/21/2018, 8:43 AM
Hey guys i need your help here am working on rxjava 2 with Kotlin and the call is keep calling on error with - HTTP 400 Bad Request
disposable!!.add(service.login(user)
            .subscribeOn(<http://Schedulers.io|Schedulers.io>())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe({ response ->
                handleResponse(response)

            }, { error ->
                Tools.log("Error ${error.message}")
                handlerError(error)
                register_progress!!.dismiss()

            })
        )
My problem i keep gettting on error … even if the call is successful ….i get null
g

gildor

12/21/2018, 8:44 AM
Get null where?
I didn’t get, do you have 400 and onError, or success and null (but not sure where, because RxJava2 doesn’t allow emit null)?
k

Kevin Janvier Chinabalire

12/21/2018, 9:00 AM
@gildor when i make a call on error is being called .. i expect response -> to be called because i have a check there I do a check like this on response :
if (login.success) {
            //save the details
            Apps.pref.token = login.token
            //save into the local DB
        

            saveDetails(login)
        } else {
            //display a message
          //  error message here


        }
do u know why
response
is not being called when the result false .. and i have a check there
g

gildor

12/21/2018, 9:01 AM
on error is being called
And what is in this error? What is throwable type and message?
k

Kevin Janvier Chinabalire

12/21/2018, 9:02 AM
i log the message like this error.message then i get
HTTP 401 Unauthorized
i making a post
g

gildor

12/21/2018, 9:05 AM
So, 401
you have HTTP error
I suppose you use Retrofit with RxJava2 adapter
if so, this is how RxJava2 adapter works, emits errors to RxJava onError callback
I still not sure what is you problem
k

Kevin Janvier Chinabalire

12/21/2018, 9:43 AM
Okay .. let me google and see … am using rxjava2 with retrofit … a
a

Alfian Akmal Hanantio

12/22/2018, 9:33 AM
you can add logger to OKHttpClient to log request and response to your API
k

Kevin Janvier Chinabalire

02/26/2019, 5:52 AM
Yea