How to throw error if data is invalid #7469
-
const queryClient = new QueryClient({
defaultOptions: {
queries: {
onSuccess: (data: any) => {
// Eden Treaty doesn't throw errors I raised an issue:
// https://github.com/elysiajs/elysia/issues/651
// throw it ourselves so we can properly depend on `error` being filled
if (typeof data === 'object' && data.error) {
throw new Error(data.error)
}
},
useErrorBoundary: true,
},
},
}) This doesn't work as expected because the error is actually thrown into the app. I don't want to wrap every component that uses useQuery in a boundary (and that is too broad anyway). What I expected was that the |
Beta Was this translation helpful? Give feedback.
Answered by
TkDodo
May 22, 2024
Replies: 1 comment
-
you would do that from within the queryFn. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
dominictobias-bullish
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you would do that from within the queryFn.
onSuccess
is deprecated in v4 and was removed in v5