Can't filter out operational errors anymore using custom flag in error object.
kebetsi opened this issue · comments
Ilia Kebets commented
A way to filter out operational errors
Relevant Package
Upgraded from airbrake-js@1.6.8 to @airbrake/node@1.1.2 + airbrake/browser@1.1.2
Description
I used to flag operational errors so they wouldn't get reported to airbrake by a flag in the error that was caught by the express error middleware using the filter as following:
airbrake.addFilter(function (notice) {
if (notice.environment['err.dontNotifyAirbrake']) {
return null;
}
return notice;
});
With the new version of airbrake (@airbrake/node), there is no way to access error flags as they are stripped by the base_notifier.processor as shown here.
Describe the solution you'd like
Can there be a property such as userContext
where I could put some custom flags on which I can filter the notified errors in the later?
Describe alternatives you've considered
I have considered:
- forking airbrake/airbrake-js and adding the field
- rollback to airbrake-js
- stop using the express error handler and use .notify()
Kyrylo Silin commented
This is how you can achieve the old behavior with @airbrake/browser
v2.1.8:
airbrake.addFilter((notice) => {
if (notice.environment['err.dontNotifyAirbrake']) {
return null;
}
return notice;
});
airbrake.notify({
error: 'will not be reported',
environment: { 'err.dontNotifyAirbrake': true },
});