Koltin, Sealed Classes In Kotlin, Android.
Kotlin sealed class DownloadResult { data class Success(val data: String) : DownloadResult() data class Error(val exception: Throwable) : DownloadResult() } suspend fun downloadData(): DownloadResult { // ... download logic try { val data = // ... download data return DownloadResult.Success(data) }