Skip to content

Commit

Permalink
fix: serializers fix
Browse files Browse the repository at this point in the history
  • Loading branch information
y9san9 committed Nov 1, 2023
1 parent 7b0804c commit 6aad1c3
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ import kotlinx.serialization.json.Json

@Serializable(with = ServerResponse.Serializer::class)
internal sealed interface ServerResponse<out T> {
@Serializable

data class Error(
val errorCode: Int,
val errorMessage: String
) : ServerResponse<Nothing>

@Serializable
data class Success<T>(val result: T) : ServerResponse<T>

@Suppress("UNCHECKED_CAST")
Expand Down Expand Up @@ -64,5 +63,5 @@ internal fun <T> Payload.decodeToServerResponse(
}

internal suspend inline fun <reified T : Any> HttpResponse.bodyAsSuccess(): T {
return body<ServerResponse.Success<T>>().result
return (body<ServerResponse<T>>() as ServerResponse.Success).result
}

0 comments on commit 6aad1c3

Please sign in to comment.