You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, the Error returned in the useQuery hook is still of type Error. This makes a lot of sense since how would useQuery know what kind of Error is returned, and an Error can basically be anything.
Was just wondering how other developers handle these kind of cases, to still get typesafety on Errors returned from useQuery.
For some reason type assertion is not working either for me (the following never logs anything):
if (error instanceof PostgrestError) {
console.log(error.code)
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
I recently got into tanstack Query and I am amazed by how smooth everything works, so first of all massive thanks to the creators/maintainers ♥.
I was wondering one thing, is it possible to get an extend of an Error through useQuery.
Example query:
this query can return a PostgrestError which looks like this:
However, the Error returned in the useQuery hook is still of type Error. This makes a lot of sense since how would useQuery know what kind of Error is returned, and an Error can basically be anything.
Was just wondering how other developers handle these kind of cases, to still get typesafety on Errors returned from useQuery.
For some reason type assertion is not working either for me (the following never logs anything):
Help is greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions