M
process.addUncaughtExceptionCaptureCallback
History
Added in: v25.9.0
v25.9.0
Introduced in: v0.10.0
v0.10.0
process.addUncaughtExceptionCaptureCallback(fn): void
Stability: 1Experimental
Attributes
fn:
FunctionThe process.addUncaughtExceptionCaptureCallback() function adds a callback
that will be invoked when an uncaught exception occurs, receiving the exception
value as its first argument.
Unlike process.setUncaughtExceptionCaptureCallback(), this function allows
multiple callbacks to be registered and does not conflict with the
domain module. Callbacks are called in reverse order of registration
(most recent first). If a callback returns true, subsequent callbacks
and the default uncaught exception handling are skipped.
import process from 'node:process'; process.addUncaughtExceptionCaptureCallback((err) => { console.error('Caught exception:', err.message); return true; // Indicates exception was handled });
process.addUncaughtExceptionCaptureCallback((err) => { console.error('Caught exception:', err.message); return true; // Indicates exception was handled });