Electron how to report console error


Is it possible for Sentry to report electron console errors?

I have found a similar question here. But I don’t want to use another library.

This worked

const consoleError = console.error;

console.error = (message) => {
  consoleError("---->", message);

I am not sure if there is a better way