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.
This commit is contained in:
Ferdinand Prantl
2019-07-15 14:43:22 +02:00
parent c100bb6242
commit df4b6e58e2

View File

@@ -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];
}