diff --git a/core/support/src/main/kotlin/au/com/dius/pact/core/support/Result.kt b/core/support/src/main/kotlin/au/com/dius/pact/core/support/Result.kt index c30132d84..2de43b0ad 100644 --- a/core/support/src/main/kotlin/au/com/dius/pact/core/support/Result.kt +++ b/core/support/src/main/kotlin/au/com/dius/pact/core/support/Result.kt @@ -72,4 +72,18 @@ fun Result.getOrElse(function: (E) -> V): V { } } +fun Result.orElse(function: (E) -> Result): Result { + return when (this) { + is Result.Err -> function(error) + is Result.Ok -> this + } +} + +fun Result.or(default: Result): Result { + return when (this) { + is Result.Err -> default + is Result.Ok -> this + } +} + class UnwrapException(message: String): RuntimeException(message)