fix(zone.js): don't wrap uncaught promise error. (#31443)
Close #27840 PR Close #31443
This commit is contained in:

committed by
Miško Hevery

parent
6b51ed29ef
commit
2bb9a65351
@ -345,11 +345,8 @@ describe(
|
||||
});
|
||||
setTimeout((): any => null);
|
||||
setTimeout(() => {
|
||||
expect(promiseError !.message)
|
||||
.toBe(
|
||||
'Uncaught (in promise): ' + error +
|
||||
(error !.stack ? '\n' + error !.stack : ''));
|
||||
expect((promiseError as any)['rejection']).toBe(error);
|
||||
expect(promiseError).toBe(error);
|
||||
expect((promiseError as any)['zone']).toBe(zone);
|
||||
expect((promiseError as any)['task']).toBe(task);
|
||||
done();
|
||||
@ -389,6 +386,39 @@ describe(
|
||||
});
|
||||
});
|
||||
|
||||
it('should print original information when throw a not error object with a message property',
|
||||
(done) => {
|
||||
let promiseError: Error|null = null;
|
||||
let zone: Zone|null = null;
|
||||
let task: Task|null = null;
|
||||
let rejectObj: TestRejection;
|
||||
queueZone
|
||||
.fork({
|
||||
name: 'promise-error',
|
||||
onHandleError: (delegate: ZoneDelegate, current: Zone, target: Zone, error: any):
|
||||
boolean => {
|
||||
promiseError = error;
|
||||
delegate.handleError(target, error);
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.run(() => {
|
||||
zone = Zone.current;
|
||||
task = Zone.currentTask;
|
||||
rejectObj = new TestRejection();
|
||||
rejectObj.prop1 = 'value1';
|
||||
rejectObj.prop2 = 'value2';
|
||||
(rejectObj as any).message = 'rejectMessage';
|
||||
Promise.reject(rejectObj);
|
||||
expect(promiseError).toBe(null);
|
||||
});
|
||||
setTimeout((): any => null);
|
||||
setTimeout(() => {
|
||||
expect(promiseError).toEqual(rejectObj as any);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Promise.race', () => {
|
||||
it('should reject the value', () => {
|
||||
queueZone.run(() => {
|
||||
|
Reference in New Issue
Block a user