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

fix(error): fix #706, handleError when onHasTask throw error #709

Merged
merged 1 commit into from
Apr 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/zone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,7 @@ const Zone: ZoneType = (function(global: any) {
this._hasTaskZS.onHasTask(
this._hasTaskDlgt, this._hasTaskCurrZone, targetZone, isEmpty);
} catch (err) {
this.handleError(targetZone, err);
}
}

Expand Down
19 changes: 19 additions & 0 deletions test/common/zone.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,25 @@ describe('Zone', function() {
JSON.stringify(macro);
}).not.toThrow();
});

it('should call onHandleError callback when zoneSpec onHasTask throw error', () => {
const spy = jasmine.createSpy('error');
const hasTaskZone = Zone.current.fork({
name: 'hasTask',
onHasTask: (delegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
hasTasState: HasTaskState) => {
throw new Error('onHasTask Error');
},
onHandleError:
(delegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, error: Error) => {
spy(error.message);
return delegate.handleError(targetZone, error);
}
});

const microTask = hasTaskZone.scheduleMicroTask('test', () => {}, null, () => {});
expect(spy).toHaveBeenCalledWith('onHasTask Error');
});
});
});

Expand Down