core / pragma /

Package pragma #

Types #

NameSummary

ApplicationErrorException

class ApplicationErrorException(errorMessage: GeneratedMessageV3) : RuntimeException

Base class for application errors. These are filtered out in Service’s requestRpc function and treated as "successful" calls that return the message passed to the exception as the response.

PragmaResult

sealed class PragmaResult<out TSuccess, out TFailure>

A discriminated union that encapsulates a successful outcome with a value of type TSuccess or a failure with of type TFailure. Similar to kotlin.Result, but with non-exception failures.

Functions #

NameSummary

andThen

inline fun <TNewSuccess, TNewFailure, TSuccess, TFailure : TNewFailure> PragmaResult<TSuccess, TFailure>.andThen(onSuccess: (TSuccess) -> PragmaResult<TNewSuccess, TNewFailure>): PragmaResult<TNewSuccess, TNewFailure>

Returns the result of the given onSuccess function applied to the encapsulated TSuccess if this instance represents success or the original encapsulated value if it is failure.

applicationError

inline fun applicationError(builder: () -> GeneratedMessageV3): Nothing

Throws an ApplicationErrorException similar to kotlin.error

applicationRequire

inline fun applicationRequire(value: Boolean, lazyError: () -> GeneratedMessageV3)

Throws an ApplicationErrorException if the value is false. Similar to kotlin.require

applicationRequireNotNull

inline fun <T : Any> applicationRequireNotNull(value: T?, lazyError: () -> GeneratedMessageV3): T

Throws an ApplicationErrorException if the value is null. Otherwise, returns the not null value. Similar to kotlin.requireNotNull

failureOrElse

inline fun <TNewFailure, TSuccess, TFailure : TNewFailure> PragmaResult<TSuccess, TFailure>.failureOrElse(onFailure: (TSuccess) -> TFailure): TFailure

Returns the encapsulated value if this instance represents failure or the result of onFailure function for the encapsulated TSuccess if it is success.

getOrDefault

inline fun <TSuccess, TFailure> PragmaResult<TSuccess, TFailure>.getOrDefault(onFailure: () -> TSuccess): TSuccess

Returns the encapsulated value if this instance represents success or the result of if it is failure.

getOrElse

inline fun <TNewSuccess, TSuccess : TNewSuccess, TFailure> PragmaResult<TSuccess, TFailure>.getOrElse(onFailure: (TFailure) -> TSuccess): TSuccess

Returns the encapsulated value if this instance represents success or the result of onFailure function for the encapsulated TFailure if it is failure.

map

inline fun <TNewSuccess, TSuccess : TNewSuccess, TNewFailure, TFailure : TNewFailure> PragmaResult<TSuccess, TFailure>.map(transform: (TSuccess) -> TNewSuccess): PragmaResult<TNewSuccess, TNewFailure>

Returns the result of the given transform function applied to the encapsulated value if this instance represents success or the original encapsulated TFailure value if it is failure.

orElse

inline fun <TNewSuccess, TNewFailure, TSuccess : TNewSuccess, TFailure> PragmaResult<TSuccess, TFailure>.orElse(onFailure: (TFailure) -> PragmaResult<TNewSuccess, TNewFailure>): PragmaResult<TNewSuccess, TNewFailure>

Returns the result of the given onFailure function applied to the encapsulated TFailure if this instance represents failure or the original encapsulated value if it is success.

recover

inline fun <TNewSuccess, TSuccess : TNewSuccess, TFailure> PragmaResult<TSuccess, TFailure>.recover(transform: (TFailure) -> TNewSuccess): TNewSuccess

Returns the result of the given transform function applied to the encapsulated TFailure if this instance represents failure or the original encapsulated value if it is success.