| Start |
|---|
| try...catch block try...catch block is for handling exceptions, remember exception means the thrown error not the error. In the In the above example we modified the You can through any error in your try block and handle it in the catch block: |
| Creating Error object new Error(message) Creates new error object, where the value Each error object has stack trace. Stack trace contains the information of error message and shows where the error happened (the above output shows the error stack). Once error object is created the system captures the stack trace of the error on current line. To get the stack trace use stack property of any created error object. Below two lines are identical: |
| Throwing Error Throwing error means exception if any exception is not handled then the node server will crash. The following line throws error: or or The last example (throwing strings) is not good practice and is not recommended (always throw errors which are instances of Error object). Note that if you But in this example: |
Read Article
https://develop.horje.com/learn/1434/reference