What properties does Node.js express's Error object expose?
Asked Answered
C

1

49

I would like to know what are the functions that the Error object of nodejs express exposes for use in error handling?

A console.log of an error call new Error('NotFound') is showing only [Error: NotFound].
Is this because the .toString() method is overriden?
How do I find the properties and functions exposed by these objects?

Cauchy answered 16/5, 2012 at 18:56 Comment(1)
Check out the answer here: docs.nodejitsu.com/articles/errors/what-is-the-error-objectKenzi
G
70

The Error object is actually a native object provided by V8, rather than by node.js or express.

The property that will most likely be of the most use to you is stack. E.g.,

console.log(new Error('NotFound').stack);

There are other properties available as well, such as name and message. You can read up on them here. Just be aware that those docs are for Mozilla's JavaScript engine, so don't count on anything flagged as Non-standard to work in node.js.

Griseofulvin answered 16/5, 2012 at 19:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.