Skip to content

refactor(swift-sdk): error handling#3057

Closed
alfie-dash wants to merge 4 commits intofeat/iOSSupportfrom
refactor/phase-5-error-handling
Closed

refactor(swift-sdk): error handling#3057
alfie-dash wants to merge 4 commits intofeat/iOSSupportfrom
refactor/phase-5-error-handling

Conversation

@alfie-dash
Copy link
Copy Markdown
Contributor

Phase 5: Error Handling Utilities

Summary

  • Add centralized error handling utilities for consistent error management across the SDK
  • Create ErrorCategory enum for classifying errors by type (validation, network, authentication, etc.)
  • Add UserFacingError struct with user-friendly messages and recovery suggestions
  • Add ErrorFormatter for consistent error message formatting
  • Add ErrorRecovery for automatic recovery suggestions based on error type
  • Add ErrorCategorizer for automatic error classification
  • Add ErrorBuilder with fluent API and factory methods
  • Add ErrorAggregator for collecting multiple errors
  • Update BaseViewModel to use new error handling utilities
  • Add 35 unit tests for all error handling functionality

Files Changed

New Files:

  • Sources/SwiftDashSDK/Utils/ErrorHandling.swift - Centralized error handling types
  • SwiftExampleApp/SwiftExampleAppTests/ErrorHandlingTests.swift - Unit tests (35 tests)

Modified Files:

  • SwiftExampleApp/SwiftExampleApp/ViewModels/BaseViewModel.swift - Updated to use new error utilities

Test plan

  • All 35 ErrorHandlingTests pass
  • All existing tests continue to pass
  • Build succeeds without warnings

alfie-dash and others added 3 commits February 2, 2026 15:09
- 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>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 5, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/phase-5-error-handling

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 9, 2026

✅ 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:

  • Download 'DashSDKFFI.xcframework' artifact from the run link above.
  • Drag it into your app target (Frameworks, Libraries & Embedded Content) and set Embed & Sign.
  • If using the Swift wrapper package, point its binaryTarget to the xcframework location or add the package and place the xcframework at the expected path.

@alfie-dash alfie-dash closed this Feb 9, 2026
@alfie-dash alfie-dash deleted the refactor/phase-5-error-handling branch February 9, 2026 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant