Prevent useErrorBoundary from mutate-level onError #511
Replies: 3 comments
-
I could conditionally rethrow error from first |
Beta Was this translation helpful? Give feedback.
-
Technically, you can return a never-resolving promise to |
Beta Was this translation helpful? Give feedback.
-
For now, I'm throwing the exception myself instead of using const handlerServerErrors = useHandleServerErrors();
const [ mutate ] = useMyOwnQueryHook();
const handleSubmit = async (message) => {
try {
await mutate(payload);
} catch (error) {
return handlerServerErrors(error);
}
};
const useHandleServerErrors = () => {
const setError = useErrorState();
return (errors) => {
if (isErrorToHandleFn(error)) {
// handle error
}
setError(errors); // rethrow to render phase
};
}; I just added feature request to cover that case: #539 |
Beta Was this translation helpful? Give feedback.
-
Is it possible to prevent throwing error to render phase to ErrorBoundary, when exception is handled in
mutate
-levelonError
?Alternatively prevent
useMutation
-levelonError
:I have one customHook for many API endpoints and I want to have global handling only if the specific one is not defined.
In other words: how to rethrow error to render phase only, when exception was not handled imperatively ?
Beta Was this translation helpful? Give feedback.
All reactions