Safely captures stack trace using V8's Error.captureStackTrace if available.
This utility provides a type-safe way to use Error.captureStackTrace without needing to check for its existence at every call site.
Object to attach stack trace to (typically 'this' in an Error constructor)
Optional
Constructor function to hide from stack trace
class MyError extends Error { constructor() { super(); captureStackTrace(this, MyError); }} Copy
class MyError extends Error { constructor() { super(); captureStackTrace(this, MyError); }}
Safely captures stack trace using V8's Error.captureStackTrace if available.
This utility provides a type-safe way to use Error.captureStackTrace without needing to check for its existence at every call site.