loadError
An error encountered during the most recent attempt to load data.
var loadError: (any Error)? { get }
This value is nil
unless a load attempt failed. It contains the latest error from the underlying SharedReaderKey
. Access it from @Shared
’s projected value:
@SharedReader(.fileStorage(.users)) var users: [User] = []
var body: some View {
if let loadError = $users.loadError {
ContentUnavailableView {
Label("Failed to load users", systemImage: "xmark.circle")
} description: {
Text(loadError.localizedDescription)
}
} else {
ForEach(users) { user in /* ... */ }
}
}
When a load error occurs,
wrappedValue
retains results from the last successful fetch. Its value will update once a new load succeeds.