android5-3 Exercise 2: Failure and cancellation ============================================ try { repository.addNote(text) } catch (e: CancellationException) { throw e // let the cancellation pass through } catch (e: Exception) { message.value = "Could not save the note" } Typing "fail" makes the repository call error("Could not save"), an IllegalStateException; the generic catch sets the message and the Chapter 2 Snackbar shows "Could not save the note". If the CancellationException branch is removed: the generic "catch (e: Exception)" also catches CancellationException (it is an exception). If the ViewModel is cleared while a save is running, the coroutine is cancelled, but the code would swallow the cancellation and set a message instead of stopping, so cancellation would not propagate cleanly. (The rethrow in a sample is from the docs; the explanation is general knowledge.) Code unrun.