VOOZH about

URL: https://www.geeksforgeeks.org/node-js/node-js-process-setuncaughtexceptioncapturecallback-method/

⇱ Node.js process.setUncaughtExceptionCaptureCallback() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Node.js process.setUncaughtExceptionCaptureCallback() Method

Last Updated : 28 Apr, 2025

The process.setUncaughtExceptionCaptureCallback() method is an inbuilt application programming interface of the processing module which is used to set a callback function which will be called when an Uncaught Exception occurs. The callback function will receive the exception value as its first argument.

Syntax: 

process.setUncaughtExceptionCaptureCallback( callback_function )

Parameters: This method accepts a single parameter as mentioned above and described below.  

  • callback_function: This is a required parameter. It can be a function or null value. If it set to null, then the function will unset the callback function.

Return: It does not return any value. 

Below examples illustrate the use of process.setUncaughtExceptionCaptureCallback() method in Node.js:

Example 1:  

Output: 

false
true


Example 2:  

Output: 

no callback has been set using process.setUncaughtExceptionCaptureCallback() method
a callback has been set using process.setUncaughtExceptionCaptureCallback() method
no callback has been set using process.setUncaughtExceptionCaptureCallback() method

Note: The above program will compile and run by using the node filename.js command, only in POSIX platforms.

Reference: https://nodejs.org/api/process.html#process_process_setuncaughtexceptioncapturecallback_fn
 

Comment

Explore