fetchError
An error encountered during the most recent attempt to fetch data.
Declaration
@MainActor @preconcurrency var fetchError: (any Error)? { get }Discussion
This value is nil unless an fetch attempt failed. It contains the latest error from SwiftData. Access it from Query’s stored property:
struct RecipeList: View {
@Query var recipes: [Recipe]
var body: some View {
ErrorIndicatorView(_recipes.fetchError)
}
}