Uncaught Errors
process.on handles uncaughtException and unhandledRejection. Log and exit, do not continue running.
Example
process.on("uncaughtException", (e) => { console.log("fatal:", e.message); process.exitCode = 1; });
process.on("unhandledRejection", (r) => console.log("rejection:", r.message));
Promise.reject(new Error("lost"));Result
rejection: lost
Exercise
Rejection event.
process.on("Rejection", fn)
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.