Tsallaka zuwa abun ciki
Justice Tech School

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

What should you do after uncaughtException?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.