I have a JavaScript error object that I have caught in code. It has a name, message, stack etc that I want to log at the backend. I am using sentry for that. But before logging I want to change the name or the message of the error.
What will be the best way to do it?
I tried creating a new error and adding the original error as cause, but that did not work with sentry. It just logs the error passed as the cause of the new error.
new Error('Additional error message', { cause: originalError });
I need the rest of the properties of the error to remain the same, just need to change the name or message.
