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

Feedback for “Error Handling” #569

Open
tbdk opened this issue Feb 17, 2024 · 0 comments
Open

Feedback for “Error Handling” #569

tbdk opened this issue Feb 17, 2024 · 0 comments

Comments

@tbdk
Copy link

tbdk commented Feb 17, 2024

https://swr.vercel.app/docs/error-handling#status-code-and-error-object

This page leaves the reader with the impression that when working with const { data/trigger, error } = useSWR[Mutation], that SWR will catch any errors thrown inside the fetcher, prevent them from propagating further up by not (re-)throwing and set the error variable with the error caught. However, it is only if the option throwOnError: false has been set, that it will actually not (re-)throw.

I think that this should be made clear in the example (modified example):
const { data, error } = useSWR('/api/user', fetcher, { throwOnError: false}) and that a point should be made of it - also showing an example for why we may not want to set the option. But being very explicit about that option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant