Created reusable error handling components that can be used across all screens in both Android and iOS apps to show retry/cancel dialogs when network calls fail. Android Components: - ApiResultHandler: Composable that automatically handles ApiResult states with loading indicators and error dialogs - HandleErrors(): Extension function for ApiResult to show error dialogs for operations that don't return display data - Updated ResidencesScreen to import ApiResultHandler iOS Components: - ViewStateHandler: SwiftUI view that handles loading/error/success states with automatic error alerts - handleErrors(): View modifier for automatic error monitoring - Both use the existing ErrorAlertModifier for consistent alerts Documentation: - Created ERROR_HANDLING.md with comprehensive usage guide - Includes examples for data loading and create/update/delete operations - Migration guide for updating existing screens - Best practices and testing guidelines These utilities make it easy to add consistent error handling with retry functionality to any screen that makes network calls, improving the user experience across the entire app. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1.3 KiB
1.3 KiB
Error Handling Guide
This guide explains how to implement consistent error handling with retry/cancel dialogs across Android and iOS apps.
Android (Compose)
Components Available
- ErrorDialog - Reusable Material3 AlertDialog with retry/cancel buttons
- ApiResultHandler - Composable that automatically handles ApiResult states
- HandleErrors() - Extension function for ApiResult states
Usage Examples
See full documentation in the file for complete examples of:
- Using ApiResultHandler for data loading screens
- Using HandleErrors() extension for create/update/delete operations
- Using ErrorDialog directly for custom scenarios
iOS (SwiftUI)
Components Available
- ErrorAlertModifier - View modifier that shows error alerts
- ViewStateHandler - View that handles loading/error/success states
- handleErrors() - View extension for automatic error monitoring
Usage Examples
See full documentation for examples of each approach.
Files Reference
Android:
composeApp/src/commonMain/kotlin/com/example/mycrib/ui/components/ErrorDialog.ktcomposeApp/src/commonMain/kotlin/com/example/mycrib/ui/components/ApiResultHandler.kt
iOS:
iosApp/iosApp/Helpers/ErrorAlertModifier.swiftiosApp/iosApp/Helpers/ViewStateHandler.swift