Skip to content

Instantly share code, notes, and snippets.

@rubenquadros
Created June 12, 2022 14:50
Show Gist options
  • Save rubenquadros/9a34eb466bb6eb48037474324fb84542 to your computer and use it in GitHub Desktop.
Save rubenquadros/9a34eb466bb6eb48037474324fb84542 to your computer and use it in GitHub Desktop.
Viewmodel to perform work
class HomeViewModel : ViewModel() {
fun handleException() {
viewModelScope.launch { runCatching { doWork() } }
}
fun unhandledException() {
viewModelScope.launch { doWork() }
}
private fun doWork() {
throw CustomException()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment