blob: 58c2989fccd1a180fc1af0b9cd904bb65996d062 [file]
sealed class Result {
class Failure(val exception: Exception) : Result()
class Success(val message: String) : Result()
}
fun box(): String {
var result: Result
try {
result = Result.Success("OK")
}
catch (e: Exception) {
result = Result.Failure(Exception())
}
when (result) {
is Result.Failure -> throw result.exception
is Result.Success -> return result.message
}
}