From df4b6e58e2063b6bccb762927dcc1bb6c45376d4 Mon Sep 17 00:00:00 2001 From: Ferdinand Prantl Date: Mon, 15 Jul 2019 14:43:22 +0200 Subject: [PATCH] Pass the error including stacktrace to error handlers and reporters The global window error handler is used to handle errors thrown from within asynchronous functions and tests. The first parameter is the error; the fifth parameter is the full error object including the stacktrace. Searching for the first occurrence of an error instance to work with browsers, which may not comply with the HTML5 standard. --- src/core/GlobalErrors.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/core/GlobalErrors.js b/src/core/GlobalErrors.js index 2c58e684..e8430c1e 100644 --- a/src/core/GlobalErrors.js +++ b/src/core/GlobalErrors.js @@ -7,7 +7,12 @@ getJasmineRequireObj().GlobalErrors = function(j$) { var handler = handlers[handlers.length - 1]; if (handler) { - handler.apply(null, Array.prototype.slice.call(arguments, 0)); + // 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); } else { throw arguments[0]; }