Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The castError behavior of createResource should be documented #825

Open
suguruwataru opened this issue Jul 13, 2024 · 0 comments
Open

The castError behavior of createResource should be documented #825

suguruwataru opened this issue Jul 13, 2024 · 0 comments
Labels
help wanted Looking for assistance on this issue solid Related to core Solid

Comments

@suguruwataru
Copy link

Describe the bug

https://github.com/solidjs/solid-docs/blob/883f25e17843fff81d002a80e8f9a3344556fdaf/langs/en/api/api.md?plain=1#L403

The documentation linked above says

data.error tells you if the request has errored out; if so, it contains the error thrown by the fetcher.

The second part is not true. There is a castError function that's called which modifies the error thrown by the fetcher, making sure that data.error is always an Error object, and therefore data.error is not always what the fetcher throws:

https://github.com/solidjs/solid/blob/1afe035c80f0dc2815951e648e9fa4e8cc5e6054/packages/solid/src/reactive/signal.ts#L1687-L1690

If what the fetcher throws is a string, it becomes data.error.message. If it's neither a string nor an Error, it becomes data.error.cause.

I haven't found documentation for this and had to look at the code, but I think this is definitely something that should appear in the documentation.

Your Example Website or App

N/A

Steps to Reproduce the Bug or Issue

N/A

Expected behavior

The documentation of createResource (and maybe other places where the castError is used) should mention the behavior.

Screenshots or Videos

No response

Platform

All

Additional context

No response

@ryansolid ryansolid transferred this issue from solidjs/solid Jul 24, 2024
@LadyBluenotes LadyBluenotes added solid Related to core Solid help wanted Looking for assistance on this issue improve documentation and removed improve documentation labels Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Looking for assistance on this issue solid Related to core Solid
Projects
None yet
Development

No branches or pull requests

2 participants