Replies: 1 comment
-
add try/catch inside the queryFn / mutationFn and only re-throw the error you want after you’ve handled it. |
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
-
Hi, I was wondering if there is an option to add a prop similar to
useQuery
'sselect
to enable mapping over errors inuseQuery
(and other queries too) anduseMutation
. The only real alternative I see is to catch and rethrow it, asonError
uses the persisted state, and this is not ideal since I don't need to build the exception stack or w/e just to map over a value. It would be really helpful since in our app we have a specialuseApiMutation
hook that splits error handling into three distinct parts -BadRequest
errors,NotFound
errors andRemaining
errors, and I would like to hold only the final message in theerror
state of the mutation, to not have to move mapping of values into react's dependency tracking.Thanks for answers!
Beta Was this translation helpful? Give feedback.
All reactions