Show a better error in InterUriScreen
This commit is contained in:
parent
6c15889360
commit
a3332d8f06
2 changed files with 8 additions and 4 deletions
|
@ -87,7 +87,7 @@ fun IntentUriScreen(uri: Uri) {
|
|||
}
|
||||
} ?: uri.getQueryParameter("v")?.let { videoId ->
|
||||
YouTube.song(videoId).toNullable()?.map { listOf(it) }
|
||||
} ?: Outcome.Error.Network
|
||||
} ?: Outcome.Error.Unhandled(Error("Missing URL parameters"))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -57,9 +57,13 @@ fun <T> Outcome<T>?.toNotNull(): Outcome<T?> {
|
|||
}
|
||||
}
|
||||
|
||||
fun <T> Outcome<T?>.toNullable(): Outcome<T>? {
|
||||
return valueOrNull?.let {
|
||||
Outcome.Success(it)
|
||||
fun <T> Outcome<T?>.toNullable(error: Outcome.Error? = null): Outcome<T>? {
|
||||
return when (this) {
|
||||
is Outcome.Success -> value?.let { Outcome.Success(it) } ?: error
|
||||
is Outcome.Recovered -> value?.let { Outcome.Success(it) } ?: error
|
||||
is Outcome.Initial -> this
|
||||
is Outcome.Loading -> this
|
||||
is Outcome.Error -> this
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue