TanStackT
TanStack2y ago
3 replies
ethical-tan

Change `useQuery` error type

Hi, I'm trying to update the error type for my useQuery calls to

export class HTTPError extends Error {
  code: number;
  url: string;
  message: string;
  constructor(res: Response) {
    super(res.statusText);

    this.code = res.status;
    this.url = res.url;
    this.message = res.statusText;
  }
}


So that I can access the status codes from the component. Unfortunately Typescript isn't letting me change the error type in the way I expected (see attached image). I get a "No overload matches this call" error.

Any advice would be appreciated
image.png
Was this page helpful?