Nodejs Errors

In Nodejs we have 4 different types of errors.

  1. Standard Javascript error like reference , syntax, type etc
  2. User defined error
  3. Assertion error
  4. System error
Create a file “node-error.js” with below code. Please note “,” is missing in console.log
var a=10;
b=10;
var c= a + b;
console.log("Total - " a)

Below screenshot shows example for syntax error.

Node Js Errors

We can handle the errors using try-catch or utilizing the callback function of node js. Will see how a callback works in later section.

Subscribe Now