Bound mutate doesn't trigger SWRConfig onError #1575
Unanswered
andersnylund
asked this question in
Q&A
Replies: 4 comments
-
I have the same problem here. Is there any solutions to this problem? |
Beta Was this translation helpful? Give feedback.
0 replies
-
any hint? |
Beta Was this translation helpful? Give feedback.
0 replies
-
+1 also having this issue at the moment. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Sheittttt guess I gotta make a custom SWR Error Context implementation ;/ EDIT : My solution is just to add
Then
Kinda janky and not ideal D: maybe put it directly into your fetcher for mutates and catch it there. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to create a "global" error handling so that if either an useSWR or an mutate fails a notification will be shown. However, I am not able to get the bound mutate to cause an error that would be caught be the onError-handler in the SWRConfig that wraps the application.
I have a reproduction here: https://codesandbox.io/s/elegant-herschel-n59qk
As you can see the error thrown inside the fetcher in useSWR will cause the onError handler to log the error in the console. However the error thrown inside the mutate is not showing up in onError. However the error-object returned from useSWR call is returning the error that was caused by the mutate.
Is it possible to get the errors from bounded mutations to show up in onError-handler?
Beta Was this translation helpful? Give feedback.
All reactions