OnUnhandledRejection
注册捕获全局未处理的 Promise 拒绝的处理器。(默认启用)
此集成仅在服务器环境中(Node.js、Bun、Deno)工作。
Import name: Sentry.onUnhandledRejectionIntegration
此集成默认启用。如果您想修改默认集成,请阅读此文档。
onUnhandledRejectionIntegration
注册处理器以捕获全局未处理的 Promise 拒绝。
Copied
Sentry.init({
integrations: [Sentry.onUnhandledRejectionIntegration()],
});
Type: 'none' | 'warn' | 'strict'
此选项定义在捕获未处理的拒绝后应采取的行为,并模仿 Node.js 的 --unhandled-rejection
标志:
strict
: 将未处理的拒绝作为未捕获的异常抛出。如果异常被处理,则会触发 unhandledRejection 事件。warn
: 无论是否设置了未处理的拒绝钩子,始终触发警告,但不打印弃用警告。none
: 静默所有警告。
默认值为 none
。