commonMain.com.javiersc.resources.networkResponse.NetworkResponse.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of network-response-jvm Show documentation
Show all versions of network-response-jvm Show documentation
NetworkResponse multiplatform
package com.javiersc.resources.networkResponse
import io.ktor.http.Headers
import io.ktor.http.HttpStatusCode
import kotlinx.serialization.Contextual
import kotlinx.serialization.Serializable
/**
* Sealed class which cover usual use cases related which network responses
*/
@Serializable
public sealed class NetworkResponse {
@Serializable
public data class Success(
val data: NR,
@Contextual
val status: HttpStatusCode,
val headers: Headers,
) : NetworkResponse()
@Serializable
public data class Error(
val error: E?,
@Contextual
val status: HttpStatusCode,
val headers: Headers,
) : NetworkResponse<@Contextual Nothing, E>()
@Serializable
public data class UnknownError(
@Contextual val throwable: Throwable
) : NetworkResponse<@Contextual Nothing, @Contextual Nothing>()
@Serializable
public data class InternetNotAvailable(
val error: String
) : NetworkResponse<@Contextual Nothing, @Contextual Nothing>()
}