Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

tjmtic
Copy link
Contributor

@tjmtic tjmtic commented May 22, 2024

Fixes #1435
Fixes #1068

Added error messages to AppState to be displayed via Snackbar ( per this conversation ), and implementation for the custom tab launch failed error as described.

Also added simple tests for error list order functionality.

Now, the errorHandler can be passed to the Route level from NiaApp, and define specific errors to pass at the Screen level. This could be implemented on a per screen/viewmodel basis, but this works as a single source of truth for snackbar-bound errors.

LaunchedEffect on first error message, which prevents flickering from the LaunchedEffect when modifying the list of messages.
ErrorMessage data class for IDs, which prevents duplicate messages from preventing the LaunchedEffect firing.
I will be curious if there is a specific flow based solution to this issue.

The Offline message is still a separate Launched effect due to the value, however the snackbar handles the interaction at that point, so I believe this is the intended approach for general errors.

@tjmtic tjmtic changed the title Nia 1435b Create a general error handler which handles multiple errors - Nia 1435 May 22, 2024
@tjmtic
Copy link
Contributor Author

tjmtic commented May 24, 2024

Moved error handling responsibilities to a delegate implementation, and then added dependency injection for app and testing.

Now, this more closely resembles the implementation of the offline status, and is more generalized and reusable as a message handler. Delegation seemed more appropriate than passing an instance to avoid exposing that instance or redeclaring the add/remove message functions.

@yongsuk44
Copy link
Contributor

How about integrating the snackbars related to Bookmark and Network statuses as well?
Additionally, if there is an object that manages the error types, it might make writing test codes easier. 🤔

Include OFFLINE message in list of messages, with precedence over other messages. Pass offline value to state for use in other purposes.

Include action handling for success/failure to click snackbar button. Implementation of Bookmark UNDO function.

Moved implementations of onShowSnackbar and errorHandler closer to use case, removed unnecessary passed down parameters.
@tjmtic
Copy link
Contributor Author

tjmtic commented Jun 17, 2024

Updated the implementation with Bookmarks and Network statuses.

@yongsuk44 can you describe more what you mean about the object managing error types?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants