package com.framework.app.http

/**
 * 封装网络返回的数据
 */
sealed class Response<T> {
    companion object {
        fun <T> create(t: Throwable): FailureResponse<T> {
            return FailureResponse(t.message ?: "you know nothing")
        }

        fun <T> create(data: T): Response<T> {
            return SuccessResponse(data)
        }

        fun <T> create(): Response<T> = EmptyResponse()
    }
}

class EmptyResponse<T> : Response<T>()
data class SuccessResponse<T>(val data: T) : Response<T>()
data class FailureResponse<T>(val msg: String) : Response<T>()