CgsResult

sealed interface CgsResult<out T>

The outcome of a one-shot call that can fail: either Success with a value, or Failure with a CgsError saying why.

Calls that return this do not throw for expected failures — a lost connection, a rejected token — so there is nothing to wrap in try/catch:

when (val result = CGS.auth().authenticate(hostToken)) {
is CgsResult.Success -> proceed()
is CgsResult.Failure -> showError(result.cgsError)
}

Sealed, so a when over it needs no else and stops compiling if the SDK ever adds a case.

Parameters

T

what a successful call returns; Unit when it returns nothing.

Inheritors

Types

Link copied to clipboard
data class Failure<out T>(val cgsError: CgsError) : CgsResult<T>

The call failed.

Link copied to clipboard
data class Success<out T>(val data: T) : CgsResult<T>

The call succeeded.