我有一个快速服务器部署到 Cloud Run。如果我使用 express 中间件并将错误发送到next()
,如文档中所述,它会显示在错误报告中。
但是,如果我以report
如下各种形式使用该方法,则不会报告任何内容。
// Report an Error object
errors.report(new Error('My error message'), () => {
console.log('Done reporting Error object!');
});
// Report an error by provided just a string
errors.report('My error message', () => {
console.log('Done reporting error string!');
});
// Use the error message builder to customize all fields ...
const errorEvent = errors.event();
// Add error information
errorEvent.setMessage('My error message');
errorEvent.setUser('root@nexus');
// Report the error event
errors.report(errorEvent, () => {
console.log('Done reporting error event!');
});
我尝试将 IAM 角色“Error Reporter Writer”添加到我用于部署到 Cloud Run 的(AppEngine 默认)服务帐户中,但它仍然不起作用。
TS 编译器也不接受示例中使用的回调函数,因此要么示例已过时,要么 TS 类型定义错误。
有任何想法吗?