process.setUncaughtExceptionCaptureCallback(fn)
fn
<Function> | <null>
process.setUncaughtExceptionCaptureCallback()
函数设置一个函数,当发生未捕获的异常时将调用该函数,该函数将接收异常值本身作为其第一个参数。
如果设置了这样的函数,则不会触发 'uncaughtException'
事件。
如果 --abort-on-uncaught-exception
是从命令行传入的或通过 v8.setFlagsFromString()
设置的,则进程不会中止。
配置为对异常执行的操作(例如报告生成)也将受到影响
要取消捕获功能,可以使用 process.setUncaughtExceptionCaptureCallback(null)
。
在设置另一个捕获函数时使用非 null
参数调用此方法将引发错误。
使用此函数与使用已弃用的 domain
内置模块是相互排斥的。
fn
<Function> | <null>
The process.setUncaughtExceptionCaptureCallback()
function sets a function
that will be invoked when an uncaught exception occurs, which will receive the
exception value itself as its first argument.
If such a function is set, the 'uncaughtException'
event will
not be emitted. If --abort-on-uncaught-exception
was passed from the
command line or set through v8.setFlagsFromString()
, the process will
not abort. Actions configured to take place on exceptions such as report
generations will be affected too
To unset the capture function,
process.setUncaughtExceptionCaptureCallback(null)
may be used. Calling this
method with a non-null
argument while another capture function is set will
throw an error.
Using this function is mutually exclusive with using the deprecated
domain
built-in module.