From c1871b0f0c4fa64f6aea73aebd3759a1899b53b7 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sat, 19 Aug 2023 09:54:03 -0700 Subject: [PATCH] Removed unnecessary throw when building stack trace Since 4.0, all supported JS runtimes populate the stack property of Error objects when the Error is instantiated, not when it's thrown. --- lib/jasmine-core/jasmine.js | 6 +----- src/core/buildExpectationResult.js | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 68e875df..6939bd8f 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -2700,11 +2700,7 @@ getJasmineRequireObj().buildExpectationResult = function(j$) { } else if (options.stack) { error = options; } else { - try { - throw new Error(message()); - } catch (e) { - error = e; - } + error = new Error(message()); } } // Omit the message from the stack trace because it will be diff --git a/src/core/buildExpectationResult.js b/src/core/buildExpectationResult.js index 2170c00d..511a557c 100644 --- a/src/core/buildExpectationResult.js +++ b/src/core/buildExpectationResult.js @@ -69,11 +69,7 @@ getJasmineRequireObj().buildExpectationResult = function(j$) { } else if (options.stack) { error = options; } else { - try { - throw new Error(message()); - } catch (e) { - error = e; - } + error = new Error(message()); } } // Omit the message from the stack trace because it will be