refactor(swift-sdk): error handling#3057
Closed
alfie-dash wants to merge 4 commits intofeat/iOSSupportfrom
Closed
Conversation
- Add new validator methods to AddressValidator: - validateBech32mAddress() for bech32m Platform addresses - validateAddress() with auto-detection (hex or bech32m) - validateHash() for 32-byte hashes - validateIdentityIdHex() and isHexIdentityId() for identity IDs - Create comprehensive unit tests for all validators (40+ tests) covering AddressValidator, TransferInputValidator, WithdrawInputValidator, TopUpAddressFromAssetLockValidator, and Identity validators - Update views to use centralized validators: - AddressQueriesView: use validateHash() - DocumentWithPriceView: use isHexIdentityId() - TransitionDetailView: use isHexIdentityId()
Add DataTransformers.swift with utilities for address, number, and response transformations: - AddressTransformer: hex/Data conversion, bech32m parsing, identity ID normalization - NumberTransformer: UInt64/UInt32 parsing, amount formatting, credits/duffs to Dash - ResponseParser: PlatformAddressInfo parsing and formatting - TransferInputBuilder: create transfer inputs/outputs from form strings Update ViewModels to use new transformers: - AddressTransferViewModel: use TransferInputBuilder - WithdrawAddressFundsViewModel: use TransferInputBuilder and NumberTransformer - TopUpAddressFromAssetLockViewModel: use AddressTransformer and NumberTransformer Add comprehensive unit tests for all transformer functionality (39 tests).
- Add ErrorHandling.swift with ErrorCategory, UserFacingError, ErrorFormatter, ErrorRecovery, ErrorCategorizer, ErrorBuilder, and ErrorAggregator - Update BaseViewModel to use new error handling utilities: - Add currentError: UserFacingError for rich error information - Add handleError(message:category:) for categorized errors - Add handleValidationErrors for formatted validation messages - Add startLoading/finishLoading helpers - Add executeAsync helper for async operations - Add 35 unit tests for all error handling functionality Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Contributor
|
✅ DashSDKFFI.xcframework built for this PR.
SwiftPM (host the zip at a stable URL, then use): .binaryTarget(
name: "DashSDKFFI",
url: "https://your.cdn.example/DashSDKFFI.xcframework.zip",
checksum: "ac77439f07b572c6ab22daf19371e8c4a544e76af45177f416667d8d645b5977"
)Xcode manual integration:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 5: Error Handling Utilities
Summary
ErrorCategoryenum for classifying errors by type (validation, network, authentication, etc.)UserFacingErrorstruct with user-friendly messages and recovery suggestionsErrorFormatterfor consistent error message formattingErrorRecoveryfor automatic recovery suggestions based on error typeErrorCategorizerfor automatic error classificationErrorBuilderwith fluent API and factory methodsErrorAggregatorfor collecting multiple errorsBaseViewModelto use new error handling utilitiesFiles Changed
New Files:
Sources/SwiftDashSDK/Utils/ErrorHandling.swift- Centralized error handling typesSwiftExampleApp/SwiftExampleAppTests/ErrorHandlingTests.swift- Unit tests (35 tests)Modified Files:
SwiftExampleApp/SwiftExampleApp/ViewModels/BaseViewModel.swift- Updated to use new error utilitiesTest plan