Created
January 10, 2021 23:10
-
-
Save hadilq/8f1ed8a01a2fdd9221e92666343407dd to your computer and use it in GitHub Desktop.
Complete doWork method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun doWork(): Result<Unit> { | |
return input() into | |
::parse elseIf | |
{ | |
return Failure("Cannot parse email") | |
} into | |
::validate elseIf | |
{ | |
InvalidEmailAddress { message -> return Failure(message) } | |
EmptySubject { message -> return Failure(message) } | |
EmptyBody { message -> return Failure(message) } | |
} into | |
::send elseIf | |
{ | |
IOFailure { error -> return Failure(error.message ?: "") } | |
Timeout { error -> return Failure(error.message ?: "") } | |
UnAuthorized { error -> return Failure(error.message ?: "") } | |
} into | |
{ Success(Unit) } | |
} | |
fun parse(input: String): Result<Email> = ... | |
fun validate(input: Success<Email>): ValidationResult = ... | |
fun send(input: ValidateSuccess): SendResult = ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment