-
Notifications
You must be signed in to change notification settings - Fork 1
Closed
Labels
enhancementImprovements or additions to existing feature/codeImprovements or additions to existing feature/code
Description
Summary of Improvement
The current implementation of the DataStoreManager lacks consistent error handling and a clear categorization of errors. This update aims to improve the error-handling strategy by introducing a runDataStoreCatching function that wraps DataStore operations with specific error handling, ensuring more predictable and meaningful results when dealing with errors. Additionally, it includes a utility function to convert error types into user-friendly messages.
Current Implementation
- The
getAccessToken()andsetAccessToken()methods inDataStoreManagercurrently do not consistently handle errors. - Error handling is done using basic
try-catch, which lacks categorization or distinction between different error types (e.g., I/O issues, serialization problems). - There is no mechanism in place for converting these errors into user-friendly messages that can be shown to the user.
Proposed Solution
-
Introduce
runDataStoreCatching:- This function will wrap DataStore operations, allowing errors to be categorized into
PersistenceErrortypes (IO,SERIALIZATION,UNKNOWN). - It will return a
Resulttype, which encapsulates both successful outcomes (Result.Success) and error states (Result.Error).
- This function will wrap DataStore operations, allowing errors to be categorized into
-
Enhance
getAccessToken()andsetAccessToken():- These methods will be refactored to use
runDataStoreCatching, returning aResultobject. - This will help distinguish between successful token retrieval and potential issues like I/O or serialization errors.
- These methods will be refactored to use
-
Add
PersistenceErrorEnum:- Create a new
PersistenceErrorenum that categorizes errors that may occur during persistence operations, such asIO,SERIALIZATION, andUNKNOWN.
- Create a new
-
Create Utility Function for Error Translation:
- A new function
PersistenceError.toString()will be added to convert these errors into localized user-friendly strings, which will be displayed in the UI.
- A new function
Metadata
Metadata
Assignees
Labels
enhancementImprovements or additions to existing feature/codeImprovements or additions to existing feature/code