I have this data class ```@Serializable data class...
# getting-started
j
I have this data class
Copy code
@Serializable
data class ApiResponse<T> (

    @Serializable(with = HttpStatusCodeSerializer::class)
    val code: HttpStatusCode,

    val errors: List<KlubberError> = emptyList(),
    val data: T,
)
Does it make sense to use a type
ApiResponse<Nothing>
in case of errors? And what should I pass for the
data
parameter?
Copy code
val response = ApiResponse<Nothing> (
    code = myCode,
    errors = listOf(error1, error2),
    data = <what should I use here?>,
)
Using Unit instead of Nothing allows me to write
data = Unit
is that a better approach?
p
Copy code
sealed class ApiResponse {
	abstract val code: HttpStatusCode,

	data class StandardResponse<T>(
		override val code: HttpStatusCode,
		val data: T,
	) : ApiResponse()

	data class ErrorResponse(
		override val code: HttpStatusCode,
		val errors: List<KluberrError>,
	) : ApiResponse()
}
maybe something like this?
­čĹŹ 4
ł
Maybe make
data
nullable?
val data: T?
j
@Paul Griffith yeah I guess IÔÇÖll go with that design, I guess not having the
error
property at all in case of success is a good thing