android / nowinandroid

A fully functional Android app built entirely with Kotlin and Jetpack Compose
Apache License 2.0
15.93k stars 2.81k forks source link

Create a general error handler which handles multiple errors - Nia 1435 #1457

Closed tjmtic closed 1 month ago

tjmtic commented 1 month ago

Fixes #1435

Simple and Generic Error Handler, with a few extensible error types and an OFFLINE error (per reference to #350 ). Not exactly sure if there was something more specific to be implementing or errors to cover, so will be curious if there is a different approach here.

Included in core/ui due to the dependency reference to SnackbarHostState.

The errorHandler can be passed down through composables from NiaApp, the same way as onShowSnackbar, and then called when necessary by the ui. I am not confident in the instantiation in NiaApp, but am not sure it would be possible before then since the handler requires the snackbarHostState in this implementation.

anhtuannd commented 1 month ago

But still only one error can be displayed at a time. When the device is offline, will other errors be shown and replaced offline error?

tjmtic commented 1 month ago

Going to close this PR.

After looking more at the comment in the linked issue I think I see what the intended approach was and will update with a new PR.