TanStackT
TanStack14mo ago
7 replies
moderate-tomato

How to hide error messages in console when throwing in queryFn()?

In the docs it says to throw on errors in the queryFn, but when I do I get this error displayed in the console

This is the code I use to throw to test
export const organisationQueryOptions = (orgName: string) => queryOptions({
    queryKey: ['organisation'],
    queryFn: async (): Promise<Organization> => {throw new UnauthenticatedError("User authentication invalid, can't access " + orgName)},
})


I use router to catch the error higher up in an errorboundry, but if I step through the code, the error gets printed to the console before it steps out of query.

I checked both in a dev and production build and using both firefox and chrome, all display the same error

I feel like I'm missing something simple here, would appreciate a hand
image.png
Was this page helpful?