From 527619b0aa5cdfc7bc5f8f863680a2df8bc4f58e Mon Sep 17 00:00:00 2001 From: Ferdinand Prantl Date: Sun, 11 Aug 2019 09:31:43 +0200 Subject: [PATCH] Restore the original global error hanler to pass all parameters along --- spec/core/GlobalErrorsSpec.js | 10 ++++++++-- src/core/GlobalErrors.js | 7 ++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/spec/core/GlobalErrorsSpec.js b/spec/core/GlobalErrorsSpec.js index b4a54282..3880b041 100644 --- a/spec/core/GlobalErrorsSpec.js +++ b/spec/core/GlobalErrorsSpec.js @@ -12,7 +12,7 @@ describe('GlobalErrors', function() { expect(handler).toHaveBeenCalledWith('foo'); }); - it('prefers passing the error including stack to the handler', function() { + it('calls the global error handler with all parameters', function() { var fakeGlobal = { onerror: null }, handler = jasmine.createSpy('errorHandler'), errors = new jasmineUnderTest.GlobalErrors(fakeGlobal), @@ -23,7 +23,13 @@ describe('GlobalErrors', function() { fakeGlobal.onerror(fooError.message, 'foo.js', 1, 1, fooError); - expect(handler).toHaveBeenCalledWith(fooError); + expect(handler).toHaveBeenCalledWith( + fooError.message, + 'foo.js', + 1, + 1, + fooError + ); }); it('only calls the most recent handler', function() { diff --git a/src/core/GlobalErrors.js b/src/core/GlobalErrors.js index f62208b4..2c58e684 100644 --- a/src/core/GlobalErrors.js +++ b/src/core/GlobalErrors.js @@ -3,14 +3,11 @@ getJasmineRequireObj().GlobalErrors = function(j$) { var handlers = []; global = global || j$.getGlobal(); - var onerror = function onerror(message, source, lineno, colno, error) { + var onerror = function onerror() { var handler = handlers[handlers.length - 1]; if (handler) { - var args = Array.prototype.slice.call(arguments, 0); - // Prefer passing the error to the error handler - // to be able to print the stack trace. - handler.apply(null, error instanceof Error ? [error] : args); + handler.apply(null, Array.prototype.slice.call(arguments, 0)); } else { throw arguments[0]; }