app.cybrid.cybrid_api_id.client.infrastructure.ResponseExt.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cybrid-api-id-kotlin Show documentation
Show all versions of cybrid-api-id-kotlin Show documentation
Auto-generated Cybrid SDK for Kotlin
package app.cybrid.cybrid_api_id.client.infrastructure
import com.google.gson.GsonBuilder
import com.google.gson.JsonParseException
import retrofit2.Response
@Throws(JsonParseException::class)
inline fun Response<*>.getErrorResponse(serializerBuilder: GsonBuilder = Serializer.gsonBuilder): T? {
val serializer = serializerBuilder.create()
val reader = errorBody()?.charStream()
if (reader != null) {
return serializer.fromJson(reader, T::class.java)
}
return null
}