Checking for Error.captureStackTrace is sufficient to determine if an environment
supports stack traces. This avoids unnecessarily triggering debuggers configured
to halt when an error is thrown.

Fixes issue 6617