Nodejs Errors
In Nodejs we have 4 different types of errors.
- Standard Javascript error like reference , syntax, type etc
- User defined error
- Assertion error
- 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.
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.