refactor: Remove FlowError and move noTasksToExecute to StoreError#16
Merged
takeshishimada merged 2 commits intomainfrom Oct 31, 2025
Merged
Conversation
FlowError contained a mix of framework-level and application-level
errors, violating separation of concerns. This refactoring clarifies
the responsibility boundaries:
**Changes:**
1. **Removed FlowError entirely**
- validationFailed, networkError, stateError etc. are
application-domain concerns
- Framework should not dictate application error types
- Applications should define their own domain-specific errors
2. **Created dedicated StoreError.swift**
- Moved noTasksToExecute from FlowError to StoreError
- StoreError now contains only framework-level errors:
* deallocated: Store lifecycle error
* cancelled: Task cancellation
* noTasksToExecute: API misuse detection
3. **Updated Examples to use custom error types**
- RetryNetworkFeature: RetryError
- MultiStepWizardFeature: WizardError
- PaginatedListFeature: PaginationError
- Demonstrates proper application error design
4. **Updated documentation**
- README examples now show custom error type patterns
- Removed FlowError references throughout
**Rationale:**
- Framework errors (StoreError) vs Application errors (custom enums)
- Better separation of concerns
- More flexible for application developers
- Follows single responsibility principle
All tests passing. No breaking changes to public API except removal
of FlowError (which should be replaced with app-specific errors).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Fixed a missed reference to FlowError in the .loadFailed action handler that was not caught by the previous refactoring. Changed: - vfError -> paginationError - .networkError -> .fetchFailed 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
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.
Summary
Removes
FlowErrorentirely and movesnoTasksToExecutetoStoreError, clarifying the separation between framework-level and application-level errors.Problem
FlowErrorviolated separation of concerns by mixing:noTasksToExecute(API misuse detection)validationFailed,networkError,stateError(domain logic)This design forced applications to use framework-defined error types instead of defining their own domain-specific errors.
Solution
1. Removed FlowError completely
Application-domain errors (
validationFailed,networkError,stateError, etc.) should be defined by each application, not by the framework.2. Created dedicated StoreError.swift
Moved
noTasksToExecutefromFlowErrortoStoreError.StoreErrornow contains only framework-level errors:deallocated: Store lifecycle errorcancelled: Task cancellationnoTasksToExecute: API misuse detection3. Updated Examples with custom error types
Demonstrates proper application error design:
RetryError(maxRetriesExceeded, networkFailure)WizardError(validationFailed, submissionFailed)PaginationError(fetchFailed)4. Updated documentation
Examples/AdvancedPatterns/README.mdnow shows custom error type patternsChanges
Deleted
Sources/Flow/Store/FlowError.swiftTests/UnitTests/Store/FlowErrorTests.swiftAdded
Sources/Flow/Store/StoreError.swiftwith comprehensive documentationModified
Sources/Flow/Store/ActionTask.swift- Updated documentation referencesSources/Flow/Store/Store.swift- Removed inline StoreError definition, updated commentsExamples/AdvancedPatterns/NetworkingWithRetry/RetryNetworkFeature.swift- AddedRetryErrorExamples/AdvancedPatterns/MultiStepWizard/MultiStepWizardFeature.swift- AddedWizardErrorExamples/AdvancedPatterns/PaginatedList/PaginatedListFeature.swift- AddedPaginationErrorExamples/AdvancedPatterns/README.md- Updated best practices sectionBenefits
✅ Clear separation of concerns: Framework errors vs Application errors
✅ Better flexibility: Applications define their own domain-specific errors
✅ Follows single responsibility principle: StoreError focuses on framework concerns only
✅ Improved examples: Demonstrates proper application error design patterns
Migration Guide
Applications using
FlowErrorshould define their own error types:Testing
Breaking Changes
FlowErrorhas been removed. Applications must define their own error types.🤖 Generated with Claude Code