Gathindra
03/10/2025, 3:25 PMfun run(city: String): String {
return try {
StructuredTaskScope.ShutdownOnSuccess<String>().use { scope ->
scope.fork { weatherServiceTwo.getWeather(city) }
scope.fork { weatherServiceOne.getWeather(city) }
scope.fork { weatherServiceThree.getWeather(city) }
scope.join().result()
}
} catch (e: Exception) {
println("Exception occurred: ${e.message}")
throw RuntimeException("Weather Details not found")
}
}
I tried it with Select
Builder, but it fails if one of the service calls throws an exception.jw
03/10/2025, 3:29 PMephemient
03/10/2025, 3:36 PMephemient
03/10/2025, 3:37 PM