Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit 3485c1b

Browse files
committed
fix: throw if a zone does not define an onError hook
1 parent bf5b79e commit 3485c1b

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

Diff for: test/zone.spec.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,12 @@ describe('Zone.patch', function () {
172172
expect(leaveSpy).toHaveBeenCalled();
173173
});
174174

175+
it('should throw if onError is not defined', function () {
176+
expect(function () {
177+
zone.run(throwError);
178+
}).toThrow();
179+
});
180+
175181
it('should fire onError if a function run by a zone throws', function () {
176182
var errorSpy = jasmine.createSpy();
177183
var myZone = zone.fork({
@@ -180,9 +186,9 @@ describe('Zone.patch', function () {
180186

181187
expect(errorSpy).not.toHaveBeenCalled();
182188

183-
myZone.run(function () {
184-
throw new Error('test');
185-
});
189+
expect(function () {
190+
myZone.run(throwError);
191+
}).not.toThrow();
186192

187193
expect(errorSpy).toHaveBeenCalled();
188194
});
@@ -222,3 +228,7 @@ describe('Zone.patch', function () {
222228
});
223229

224230
});
231+
232+
function throwError () {
233+
throw new Error();
234+
}

Diff for: zone.js

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ Zone.prototype = {
4242
} catch (e) {
4343
if (zone.onError) {
4444
zone.onError(e);
45+
} else {
46+
throw e;
4547
}
4648
} finally {
4749
this.onZoneLeave();

0 commit comments

Comments
 (0)