Node Process Manager

Node.js Error Object - Error Handling

Nodejs

Free Online Tutorials on JavaScript, Node.js, React.js, PHP, JAVA, Python, HTML, GraphQl, TypeScript, MEAN, MERN Stack, etc.

Node.js Error Handling

How to handle errors using Error Object in Node.js?

An error object is an object that is either an instance of the Error, or extends the Error class.

throw new Error('Ran out of coffee')

You can extends Error class like below:

class NotFoundError extends Error {
  //...
}
throw new NotFoundError
Previous Page