Skip to content

[Bug]: TopicScreen crashes when TopicUiState.Error is emitted (TODO() in production) #2108

@Noahs212

Description

@Noahs212

Is there an existing issue for this?

  • I have searched the existing issues

Is there a StackOverflow question about this issue?

  • I have searched StackOverflow

What happened?

TopicScreen calls kotlin.TODO() for the TopicUiState.Error branch, which throws NotImplementedError at runtime and crashes the screen whenever the underlying topic flow surfaces an error.

Reachability:

  • TopicViewModel.topicUiState runs topicsRepository.getTopic(id).asResult().
  • core.common.result.Result.asResult catches any Throwable from upstream and emits Result.Error(it) (see core/common/.../result/Result.kt:32).
  • TopicViewModel maps Result.Error -> TopicUiState.Error (TopicViewModel.kt:131).
  • TopicScreen then hits TopicUiState.Error -> TODO() (TopicScreen.kt:132) and crashes.

Any exception thrown by the Room flow (DB IO error, mapper failure, etc.) or any upstream operator therefore crashes the topic detail screen instead of showing an error UI.

The branch is also untested: TopicScreenTest only drives TopicUiState.Loading and TopicUiState.Success.

Relevant logcat output

```shell
FATAL EXCEPTION: main
kotlin.NotImplementedError: An operation is not implemented.
at com.google.samples.apps.nowinandroid.feature.topic.impl.TopicScreenKt.TopicScreen(TopicScreen.kt:132)
```

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions