mirror of https://github.com/tuskyapp/Tusky.git
Browse Source
* don't hide potential timeline bugs by catching all exceptions * fix NetworkTimelineRemoteMediatorTest * improve ifExpected function * fix code formattingpull/2367/head^2
7 changed files with 39 additions and 22 deletions
@ -0,0 +1,17 @@
|
||||
package com.keylesspalace.tusky.components.timeline.util |
||||
|
||||
import retrofit2.HttpException |
||||
import java.io.IOException |
||||
|
||||
fun Throwable.isExpected() = this is IOException || this is HttpException |
||||
|
||||
inline fun <T> ifExpected( |
||||
t: Throwable, |
||||
cb: () -> T |
||||
): T { |
||||
if (t.isExpected()) { |
||||
return cb() |
||||
} else { |
||||
throw t |
||||
} |
||||
} |
||||
Loading…
Reference in new issue