https://kotlinlang.org logo
#arrow
Title
# arrow
s

sitepodmatt

03/06/2019, 3:52 PM
Copy code
val remoteInput = Option.fromNullable(getRemoteInput())
        val output  = remoteInput
            .toEither { Exception("No input") }
            .flatMap { input ->
                if(input.isNullOrBlank()) Exception("Blank input").left() else input.trim().right()
            }
            .handleErrorWith {
                // do some logging
              Option.fromNullable(getAlternativeRemoteInput()).toEither { Exception("No input")}... and so on
            }