Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/source/tutorial/08-add-a-details-view.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,17 @@ Then, in the `try` block, check for `response.hasErrors()` and wrap the result i
}
```

You should also update the conditional expression to handle the `ApplicationError` case:

```kotlin title="app/src/main/java/com/example/rocketreserver/LaunchDetails.kt"
when (val s = state) {
Loading -> Loading()
is ApplicationError -> ErrorMessage(text = s.errors.first().message) // highlight-line
is ProtocolError -> ErrorMessage("Oh no... A protocol error happened: ${s.exception.message}")
is Success -> LaunchDetails(s.data)
}
```

`response.errors` contains details about any errors that occurred. Note that this code also null-checks `response.data!!`. In theory, a server should not set `response.data == null` and `response.hasErrors == false` at the same time, but the type system cannot guarantee this.

To trigger an error, replace `LaunchDetailsQuery(launchId)` with `LaunchDetailsQuery("invalidId")`. Disable airplane mode and select a launch. The server will send this response:
Expand Down