Replies: 7 comments 13 replies
-
The fetcher is supposed to catch errors itself and use Promise.reject to return them. |
Beta Was this translation helpful? Give feedback.
-
The problem is that it is the read that throws. Either use an ErrorBoundary or guard the read with error.. ie.. don't read from the value if there is an error. |
Beta Was this translation helpful? Give feedback.
-
@ryansolid I'm working on a creating a solidjs crash course and facing the same issue. export const fetchSelectedRequest = ({ params }: RouteDataFuncArgs) => {
const [request] = createResource(
() => params.id,
() =>
new Promise((resolve, reject) => {
setTimeout(() => {
const match = restRequests()?.find((r) => r.id === params.id);
if (!match) {
throw new Error("WhAT"); // or use reject("Request not found");
}
resolve(match);
}, 500);
})
);
return request;
}; Template: <Switch>
<Match when={request.loading}>
<div>Loading...</div>
</Match>
<Match when={!request.loading && request()}>
<RestClientForm
request={request()}
actionBtnText={"Send"}
formSubmit={onFormSubmit}
formUpdate={onFormValUpdate}
/>
</Match>
<Match when={request.error || !request()}>
<div>Request Not found</div>
</Match>
</Switch> The I believe one would assume that the |
Beta Was this translation helpful? Give feedback.
-
I also found the error handling of It would be nice if we can have more details about it in the docs. And I'm recording the problem I encountered when using This works: <Switch fallback={<div>Fallback</div>}>
<Match when={data.loading}>
<div>Loading</div>
</Match>
<Match when={data.error}>
<div>Error</div>
</Match>
<Match when={data()}>
<Data data={data()} />
</Match>
</Switch> But this don't ( <Switch fallback={<div>Fallback</div>}>
<Match when={data.loading}>
<div>Loading</div>
</Match>
<Match when={data()}>
<Data data={data()} />
</Match>
<Match when={data.error}>
<div>Error</div>
</Match>
</Switch> |
Beta Was this translation helpful? Give feedback.
-
Sadly no :( |
Beta Was this translation helpful? Give feedback.
-
Hello from 2024, I'm also suffering from this issue and my use-case seems to be slightly different: const [resource] = createResource(input, () => await process(input()); } All I want from the resource in my case is |
Beta Was this translation helpful? Give feedback.
-
Hi, I got a similar issue (the component doesn't respond after the resource throws an exception) and I have a few thoughts:
|
Beta Was this translation helpful? Give feedback.
-
Playground Link
After the user enters '5', the query function no longer works and can not query other numbers.
Why does it continue to query after an error but not update the results?
Beta Was this translation helpful? Give feedback.
All reactions