SolidJSS
SolidJSโ€ข3y agoโ€ข
2 replies
Khyonn

Is there some cases where createResource doesn't handle errors ?

Hello,

I have this particular case where I'm fetching data based on searchParams and I have a basic error from the back-end:
const [baseUrl] = useContext(ARandomContext)
const [searchParams] = useSearchParams()
const source = () => ({ baseUrl: baseUrl(), params: { foo: searchParams.bar } })
const [data] = createResource(source, ({ baseUrl, params }) => api.get(baseUrl, params)) // Correct request URL / Params -> HTTP 404 ... 


My fetcher return a rejected promise, but it seems that it's not handled by createResource. I tryed to reproduce my case on a simpler example but I didn't succeed.

I patched my issue using a catch manually in the createResource fetcher, but well ... I can't use native error handling mechanism (and ofc I could also have use ErrorBoundary but it didn't suit my needs)
Anyway, all this context that brings me to my main question : what are the cases that make createResource not handling error
Was this page helpful?