Skip to content

Instantly share code, notes, and snippets.

@u0705666
Created June 8, 2023 04:41
Show Gist options
  • Save u0705666/b1992dab6739e51e0f620df657c276a9 to your computer and use it in GitHub Desktop.
Save u0705666/b1992dab6739e51e0f620df657c276a9 to your computer and use it in GitHub Desktop.
ApiResult definiation
sealed class ApiResult<out T> {
// HTTP 200
data class Success<T>(val data: T) : ApiResult<T>()
// HTTP 400..500
data class Failure(val code: Int, val message: String): ApiResult<Nothing>()
// Socket timeout, write in Demo, IO, , JSON parsing, NPE etc
data class NetworkError(val throwable: Throwable, val message: String, val networkErrorExceptions: ClassifiedNetworkErrorExceptions) : ApiResult<Nothing>()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment