Node.js process.report.reportOnUncaughtException Property
The process object is a global that provides information about, and control over, the current Node.js process. As a global, it is always available to Node.js applications without using require(). It can also be explicitly accessed using require() as shown below:
const process = require('process');
If process.report.reportOnUncaughtException is true, a diagnostic report is generated on uncaught exception.
Syntax:
process.report.reportOnUncaughtException
Parameters: This property does not accept any parameter.
Return Value: This property returns a boolean value.
Below examples illustrate the use of the process.report.reportOnUncaughtException property in Node.js:
Example 1:
index.js
// Node.js program to demonstrate the // process.report.reportOnUncaughtException Property // Include process module const process = require( 'process' ); // Printing process.report.reportOnUncaughtException property value console.log(`Report on exception: ${process.report.reportOnUncaughtException}`); |
Run the index.js file using the following command:
node index.js
Output:
Report on exception: false
Example 2:
index.js
// Node.js program to demonstrate the // process.report.reportOnUncaughtException Property // Include process module const process = require( 'process' ); process.report.reportOnUncaughtException = true ; // Printing process.report.reportOnUncaughtException property value console.log(`Report on exception: ${process.report.reportOnUncaughtException}`); |
Run the index.js file using the following command:
node index.js
Output:
Report on exception: true
Reference: https://nodejs.org/api/process.html#process_process_report_reportonuncaughtexception
Please Login to comment...