Replies: 7 comments 14 replies
|
The fetcher is supposed to catch errors itself and use Promise.reject to return them. |
|
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. |
|
@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 |
|
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> |
Sadly no :( |
|
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 |
|
Hi, I got a similar issue (the component doesn't respond after the resource throws an exception) and I have a few thoughts:
|

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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?
All reactions