Fix for undefined Error.captureStackTrace.