I have this data class
@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?
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?