commonMain.SpineFailure.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spine Show documentation
Show all versions of spine Show documentation
Multiplatform API declaration
The newest version!
package opensavvy.spine
sealed class SpineFailure {
abstract val type: Type
abstract val payload: Payload?
data class Message(
override val type: Type,
val message: String? = null,
) : SpineFailure() {
override val payload: Nothing?
get() = null
override fun toString() = "$type: “${message}”"
}
data class Payload(
override val type: Type,
override val payload: Payload,
) : SpineFailure() {
override fun toString() = "$type: “${payload}”"
}
enum class Type {
Unauthenticated,
Unauthorized,
NotFound,
InvalidRequest,
InvalidState,
;
}
}
fun SpineFailure(
type: SpineFailure.Type,
message: String? = null,
) = SpineFailure.Message(type, message)
fun SpineFailure(
type: SpineFailure.Type,
payload: Payload,
) = SpineFailure.Payload(type, payload)