How to catch custom errors throwing in apollo link?


const customLink = new ApolloLink((operation, forward) => {
   throw new UnAuthorizedError()

  return forward(operation);

const client = new ApolloClient({
      createSubscriptionHandshakeLink({ url, region, auth }, httpLink)
  cache: new InMemoryCache()

In the above example, the custom error handling customLink throws an Error before forward(operation). Is there a way to capture that custom error?

If you are using React, check Error Link - Apollo GraphQL Docs

Yeah, we checked. Error Link only handles a GraphQL or network error occurs but here we need to catch Custom error

Can’t you throw a GraphQL error but customize it? As in return a custom code that you can use to handle your particular case.