Open qrpike opened 7 years ago
There's not a particularly good way to do this right now, but #180 is an older PR for roughly the change you're suggesting. The events emitted by Raven are going to need some tweaking with the changes coming for #257, so I'll make sure to keep this in mind.
@qrpike I'm not sure whether you're referring to uncaughtExceptions but you can use something like:
const ravenEnabled = config.get('sentry.enabled');
const ravenClient = Raven.config(ravenEnabled ? ravenDsn : null).install(function(logged, err) {
log.error('process is terminating due to uncaught exception', err);
process.exit(1);
});
However this function only gets called when a ravenDsn is supplied. I have opened https://github.com/getsentry/raven-node/pull/283 to address that particular deficiency with this solution.
My best workaround so far is to monkey patch raven method:
function override(object, methodName, callback) {
// eslint-disable-next-line no-param-reassign
object[methodName] = callback(object[methodName])
}
// Monkey patch 🐒
override(raven, 'captureException', original => {
return (...args) => {
// Useful for debugging
if (process.env.NODE_ENV !== 'test') {
// eslint-disable-next-line no-console
console.warn('raven.captureException', ...args)
}
original.apply(raven, args)
}
})
I have Raven setup buy my biggest issue is when I'm developing locally I still want to see the messages in my console.
Adding:
Only shows me the event ID. How can I also console log the error. Maybe like:
Thanks,