Skip to content

Instantly share code, notes, and snippets.

@TheBotBox
Created June 5, 2020 11:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheBotBox/2979bc3221382eac85dde732f483d4ca to your computer and use it in GitHub Desktop.
Save TheBotBox/2979bc3221382eac85dde732f483d4ca to your computer and use it in GitHub Desktop.
inline fun <reified E : Throwable> tryAndCatch(blockTry: () -> Unit, blockCatch: (E) -> Unit) {
try {
blockTry()
} catch (e: Exception) {
blockCatch(e as E)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment