Handling errors in createResource
My
createResource
handle fetches data from a REST API and is displayed on the screen. I have interval that calls refetch to refresh the data.
If the fetch
fails, my interval will keep running, and even if the remote service comes up, the refetch occurs, but the page never renders the new data.
Is there a better way to handle errors in my resource? I don't want to try catch and return no data, as I want to display the existing data until new data can be retrieved.4 Replies
Note that you need to refresh error boundaries yourself, they will not rerender automatically
See second arg to fallback https://docs.solidjs.com/reference/components/error-boundary
it's probably simpler to manually handle the fetching
downsides: can't use suspense
better yet
https://playground.solidjs.com/anonymous/91406f43-8def-4117-bb79-6786602052b5
thanks, yeah.. Probably manually fetching, its what I was doing before. Also found taht checking
.error
before attempting to use the resourceyeah, checking
.error
or .state === 'errored'
also works