From 7c3434723e05fad11ad5d6e6a532944e88c2fb42 Mon Sep 17 00:00:00 2001 From: Ferdinand Prantl Date: Sun, 21 Jul 2019 23:46:14 +0200 Subject: [PATCH] Use the documented interface to pick the error instance from the global error handler --- src/core/GlobalErrors.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/core/GlobalErrors.js b/src/core/GlobalErrors.js index e8430c1e..f62208b4 100644 --- a/src/core/GlobalErrors.js +++ b/src/core/GlobalErrors.js @@ -3,16 +3,14 @@ getJasmineRequireObj().GlobalErrors = function(j$) { var handlers = []; global = global || j$.getGlobal(); - var onerror = function onerror() { + var onerror = function onerror(message, source, lineno, colno, error) { var handler = handlers[handlers.length - 1]; if (handler) { - // Get error from (message, source, lineno, colno, error) var args = Array.prototype.slice.call(arguments, 0); - var error = args.find(function(arg) { - return arg instanceof Error; - }); - handler.apply(null, error ? [error] : args); + // Prefer passing the error to the error handler + // to be able to print the stack trace. + handler.apply(null, error instanceof Error ? [error] : args); } else { throw arguments[0]; }