diff --git a/src/ng/compile.js b/src/ng/compile.js index 603d94ed9522..36b64fe4e41b 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -1557,19 +1557,15 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { } // We must run this hook in an apply since the $$postDigest runs outside apply $rootScope.$apply(function() { - var errors = []; for (var i = 0, ii = onChangesQueue.length; i < ii; ++i) { try { onChangesQueue[i](); } catch (e) { - errors.push(e); + $exceptionHandler(e); } } // Reset the queue to trigger a new schedule next time there is a change onChangesQueue = undefined; - if (errors.length) { - throw errors; - } }); } finally { onChangesTtl++; diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index e65b951ff90f..ed4b2f97cfc1 100644 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -5075,8 +5075,7 @@ describe('$compile', function() { $rootScope.$apply('a = 42'); // The first component's error should be logged - var errors = $exceptionHandler.errors.pop(); - expect(errors[0]).toEqual(new Error('bad hook')); + expect($exceptionHandler.errors.pop()).toEqual(new Error('bad hook')); // The second component's changes should still be called expect($log.info.logs.pop()).toEqual(['onChange']); @@ -5084,7 +5083,7 @@ describe('$compile', function() { }); - it('should collect up all `$onChanges` errors into one throw', function() { + it('should throw `$onChanges` errors immediately', function() { function ThrowingController() { this.$onChanges = function(change) { throw new Error('bad hook: ' + this.prop); @@ -5113,10 +5112,9 @@ describe('$compile', function() { $rootScope.$apply('a = 42'); - // Both component's error should be logged - var errors = $exceptionHandler.errors.pop(); - expect(errors.pop()).toEqual(new Error('bad hook: 84')); - expect(errors.pop()).toEqual(new Error('bad hook: 42')); + // Both component's error should be logged individually + expect($exceptionHandler.errors.pop()).toEqual(new Error('bad hook: 84')); + expect($exceptionHandler.errors.pop()).toEqual(new Error('bad hook: 42')); }); }); });