2 years ago

#73831

test-img

ArchkWay

How to get string or object from "buffer"

I'm trying to get error message, but have a problem with it. I see it on debugger, but can't get access in code.debug screen with needing response

Found resolution, may be for somebody could be helpfully:

val errorJsonString: String? = (error as? HttpException)?.response()?.errorBody()?.string()
        errorJsonString?.let {
            val parsedString: JsonElement = JsonParser().parse(it)
            val e: ErrorResponse = Gson().fromJson(parsedString, ErrorResponse::class.java)
            callback(result, error, e)
        } ?: callback(result, error, null)

android

debugging

retrofit

httpexception

0 Answers

Your Answer

Accepted video resources