Request problem that only falls in catch

Asked

Viewed 37 times

0

I’m working on a new project so I don’t have much control of the code and I’ve reached a problem where the request doesn’t work or returns something where I can’t solve , it just falls into the catch.

This is the function where I call the login function()

override suspend fun authenticate(userCredentials: UserCredentials, callback: AuthView) =
    try {
        when (val result = withContext(Dispatchers.IO) { login(userCredentials) }) {
            is ResultRemote.Success -> callback.onSuccess(result.response)
            is ResultRemote.ErrorResponse -> callback.onError(result.codError.mapErrorType())
        }
    } catch (throwable: Throwable) {
        Log.e("mistake#6" , "Message:" + throwable.message.toString()  + " LocalizedMessage:" + throwable.localizedMessage.toString()
                + " Cause:" + throwable.cause.toString())
        callback.onError(throwable.mapRemoteErrors().codError.mapErrorType())

    }

login function

  override suspend fun login(userCredentials: UserCredentials): ResultRemote<UserAccessToken> {
    return try {

        val accessToken = service.login(userCredentials)
        ResultRemote.Success(
            response = accessToken
        )

    } catch (throwable: Throwable) {
        Log.e("mistake#4" , "Message:" + throwable.message.toString()  + " LocalizedMessage:" + throwable.localizedMessage.toString()
                + " Cause:" + throwable.cause.toString())
        throwable.mapRemoteErrors()
    }
}

within the service.login

 @POST(Route.AUTH)
suspend fun login(@Body login: UserCredentials): UserAccessToken

Log back:

Message: Job was cancelled Localized/ Message:Job was cancelled/ Cause: null
  • userCredentials is this null? According to the message, the cause of the error is "null" - then someone may be null.

  • I just checked and the fields are with data , I tried to remove the request from within the above functions and do the part and it worked however still needed it within the fun authenticate

  • But which Throwable are you giving? You just posted his message.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.