Open Alex009 opened 4 years ago
// now viewModelScope.launch { exceptionHandler.handle { serverRequest() }.catch<IllegalArgumentException> { // Specifying a specific exception class // Some custom handler code false // true - cancels ErrorPresenter; false - allows execution of ErrorsPresenter }.execute() // Starts code execution in `handle` lambda } // suggestion viewModelScope.launch { isLoading = true val result = exceptionHandler { action { serverRequest() } catch<IllegalAccessException> { exc -> // Some custom handler code false // true - cancels ErrorPresenter; false - allows execution of ErrorsPresenter } catch<IllegalArgumentException> { exc -> // Some custom handler code false // true - cancels ErrorPresenter; false - allows execution of ErrorsPresenter } finally { isLoading = false } } }
https://kotlinlang.org/docs/reference/type-safe-builders.html#scope-control-dslmarker-since-11