Q63: How do you create custom Error classes in Node.js?

Extend the built-in Error class and invoke super(message). Capture stack traces using Error.captureStackTrace(this, CustomErrorClass).

Key Takeaways
  • Extend the standard JavaScript Error class.
  • Use Error.captureStackTrace() to preserve clean stack trace histories.
Knowledge Check

Which V8 method captures formatted call stack lines on custom error objects?