Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error handling #40

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open

Error handling #40

wants to merge 18 commits into from

Conversation

stephencelis
Copy link
Member

@Shared persistence strategies can fail to load or save, but we have generally silently ignored such failures. This PR explores introducing loadError and saveError properties on the projected value, similar to SwiftData's @Query's fetchError.

@Shared(.fileStorage(.syncUps)) var syncUps: [SyncUp] = []

var body: some View {
  if let loadError = $syncUps.loadError {
    ContentUnavailableView {
      Label("Failed to load sync-ups", systemImage: "xmark.circle")
    } description: {
      Text(loadError.localizedDescription)
    }
  } else {
    ForEach(syncUps) { syncUp in
      // ...
    }
  }
}

@stephencelis stephencelis marked this pull request as ready for review December 11, 2024 22:41
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