使用已弃用的客户端Raven,您可以忽略麻烦的错误:
Raven.config('your-dsn', {
ignoreErrors: [
'Can\'t execute code from freed script',
/SecurityError\: DOM Exception 18$/
]
}).install();
我在新客户端找到的唯一方法是使用before-send
钩子:https://docs.sentry.io/error-reporting/configuration/filtering/?platform=browser#before-send
import * as Sentry from '@sentry/browser';
init({
beforeSend(event, hint) {
const { message } = hint.originalException;
if (message && message.match(/database unavailable/i)) {
return null;
}
return event;
}
});
我搜遍了所有文档,但没有找到忽略错误的全局方法。
似乎有一个ignoreErrors
配置选项。它在他们的示例应用程序中记录在这里:
普通JS:
process.on('unhandledRejection', (reason, promise) => {
//console.log('(Custom message) Unhandled Rejection found at:', reason.stack, reason.caputureStackTrace);
console.log('Unhandled Rejection at: Promise', promise, 'reason:', reason, reason.constructor.name);
});
我想你的正则表达式不匹配,尝试:/SecurityError\\: DOM Exception 18$/
而不是/SecurityError\: DOM Exception 18$/
,请注意\\