ConfigResult

sealed class ConfigResult<out T>(source)

The outcome of loading a config: Success with the value, or Failure with every error found. Loading does not stop at the first bad key, so all problems are reported at once.

Inheritors

Types

Link copied to clipboard
data class Failure(val errors: List<ConfigError>) : ConfigResult<Nothing>

The config could not be loaded; errors lists each failed key.

Link copied to clipboard
data class Success<T>(val value: T) : ConfigResult<T>

The config loaded and passed validation.

Functions

Link copied to clipboard
fun getOrElse(fallback: T): T

The value, or fallback on failure.

Link copied to clipboard
fun getOrNull(): T?

The value, or null on failure.

Link copied to clipboard
fun getOrThrow(): T

The value, or throws ConfigException with all the errors.

Link copied to clipboard
fun <R> map(transform: (T) -> R): ConfigResult<R>

Transforms the value of a Success; a Failure is returned unchanged.

Link copied to clipboard

Runs action with the errors if this is a Failure, then returns this result.