Log error from children

Report a typo

We have an API for loading data from a server, and we need to add logging to the server so that later we can analyze errors.

Your task is to modify the main scope so that errors from all children async tasks get logged in the following format: Error: ${exception.message}.

Tip: Each exception has a property .message.

This task uses dependencies that may not be available in your local IDE. As a result, you may see compilation errors or unresolved references when running the code locally. This does not affect solution validation when you submit your solution to Hyperskill.

Write a program in Kotlin
// Define a proper scope here
// Don't ignore the error only log them
// val mainScope =

suspend fun main() {
// we load data in the main scope
// make the scope log errors thrown by `loadData`
// no need to modify this code
mainScope.loadData("http://url1").join()
mainScope.loadData("http://url2").join()
}

Create a free account to access the full topic