The optional constructorOpt parameter allows you to pass in a function value. When collecting the stack trace all
frames above the topmost call to this function, including that call, are left out of the stack trace. This can be
useful to hide implementation details that won’t be useful to the user. The usual way of defining a custom error
that captures a stack trace would be:
1function MyError() {2 // fill the stack trace, but hide the call to MyError3 Error.captureStackTrace(this, MyError);4}
Parameters:
error - The error whose stack trace should be filled.
constructorOpt - An optional filter to hide the topmost stack frames.