- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
Description
refs:
https://kotlinlang.org/docs/multiplatform-mobile-upgrade-app.html#connect-http-client
https://zenn.dev/ktrueda/articles/kotlin-jvm-0006
Exceptionをスローするfunctionは@Throws(Exception::class)
のようにアノテーションをつけたい。
これによりバイトコードレベルで functionに throws Exception
が付与される。
import io.ktor.client.call.*
import io.ktor.client.request.*
class Greeting {
// ...
@Throws(Exception::class)
suspend fun greeting(): String {
val rockets: List<RocketLaunch> =
httpClient.get("https://api.spacexdata.com/v4/launches").body()
val lastSuccessLaunch = rockets.last { it.launchSuccess == true }
return "Guess what it is! > ${platform.name.reversed()}!" +
"\nThere are only ${daysUntilNewYear()} left until New Year! 🎆" +
"\nThe last successful launch was ${lastSuccessLaunch.launchDateUTC} 🚀"
}
}
Metadata
Metadata
Assignees
Labels
Projects
Milestone
Relationships
Development
Select code repository
Activity
適切な箇所に@throwsをつける #84
Merge pull request #85 from LeoAndo/issue-84-refactor