If it possible in typescript to clone error with some modifications?

Solution 1:

  await axios.get("xxx").then(result => {
    // Success
  }).catch((err: AxiosError) => {
    Sentry.captureException({
      ...err,
      response: {
        ...err.response,
        data: "Custom error message"
      }
    });
  });

Does this approach solve the problem?