I stucked with an issue - I'm trying to use Sentry.captureException with received error, but before that i'm trying to change error message. Spent a lot of time to find an answer to my question, but i had no success. How could i create a new error with type Error | AxiosError and clone into that variable all the properties and change message? I can't use custom errors, because i don't want to change a lot of code.
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?