Skip to content

Unable to use instanceof TRPCClientError #209

@Ryanjso

Description

@Ryanjso

I'm having trouble getting errors to show up correctly as instances of the TRPCClientError class.
If you console.log(err.constructor.name) it's always _y

It seems it's being minified by Vite somewhere but I've played with the configuration a lot and can't seem to figure out anything different.

I realize this may be a Vite issue more so than an electron-trpc issue but I imagine everyone here is likely facing this so curious of a fix.

This issue happens in my own repo and this repos example basic-react project

import { TRPCClientError } from '@trpc/react-query'; // same issue even if you import from '@trpc/client'

 try {
          await mutateAsync();
        } catch (err) {
          if (err instanceof TRPCClientError) {
            // never happens :(
          } 
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions