@@ -48,6 +48,7 @@ Zone.__load_patch('Error', (global: any, Zone: ZoneType, api: _ZonePrivate) => {
48
48
let zoneAwareFrame2 : string ;
49
49
let zoneAwareFrame1WithoutNew : string ;
50
50
let zoneAwareFrame2WithoutNew : string ;
51
+ let zoneAwareFrame3WithoutNew : string ;
51
52
52
53
global [ 'Error' ] = ZoneAwareError ;
53
54
const stackRewrite = 'stackRewrite' ;
@@ -79,7 +80,8 @@ Zone.__load_patch('Error', (global: any, Zone: ZoneType, api: _ZonePrivate) => {
79
80
let i = 0 ;
80
81
// Find the first frame
81
82
while ( ! ( frames [ i ] === zoneAwareFrame1 || frames [ i ] === zoneAwareFrame2 ||
82
- frames [ i ] === zoneAwareFrame1WithoutNew || frames [ i ] === zoneAwareFrame2WithoutNew ) &&
83
+ frames [ i ] === zoneAwareFrame1WithoutNew || frames [ i ] === zoneAwareFrame2WithoutNew ||
84
+ frames [ i ] === zoneAwareFrame3WithoutNew ) &&
83
85
i < frames . length ) {
84
86
i ++ ;
85
87
}
@@ -263,59 +265,59 @@ Zone.__load_patch('Error', (global: any, Zone: ZoneType, api: _ZonePrivate) => {
263
265
264
266
let detectZone : Zone = Zone . current . fork ( {
265
267
name : 'detect' ,
266
- onHandleError : function ( parentZD : ZoneDelegate , current : Zone , target : Zone , error : any ) :
267
- boolean {
268
- if ( error . originalStack && Error === ZoneAwareError ) {
269
- let frames = error . originalStack . split ( / \n / ) ;
270
- let runFrame = false , runGuardedFrame = false , runTaskFrame = false ;
271
- while ( frames . length ) {
272
- let frame = frames . shift ( ) ;
273
- // On safari it is possible to have stack frame with no line number.
274
- // This check makes sure that we don't filter frames on name only (must have
275
- // line number)
276
- if ( / : \d + : \d + / . test ( frame ) ) {
277
- // Get rid of the path so that we don't accidentally find function name in path.
278
- // In chrome the separator is `(` and `@` in FF and safari
279
- // Chrome: at Zone.run (zone.js:100)
280
- // Chrome: at Zone.run (http://localhost:9876/base/build/lib/zone.js:100:24)
281
- // FireFox: Zone.prototype.run@http ://localhost:9876/base/build/lib/zone.js:101:24
282
- // Safari: run@http ://localhost:9876/base/build/lib/zone.js:101:24
283
- let fnName : string = frame . split ( '(' ) [ 0 ] . split ( '@' ) [ 0 ] ;
284
- let frameType = FrameType . transition ;
285
- if ( fnName . indexOf ( 'ZoneAwareError' ) !== - 1 ) {
286
- if ( fnName . indexOf ( 'new ZoneAwareError' ) !== - 1 ) {
287
- zoneAwareFrame1 = frame ;
288
- zoneAwareFrame2 = frame . replace ( 'Error.' , '' ) ;
289
- } else {
290
- zoneAwareFrame1WithoutNew = frame ;
291
- zoneAwareFrame2WithoutNew = frame . replace ( 'Error.' , '' ) ;
292
- }
293
- blackListedStackFrames [ zoneAwareFrame2 ] = FrameType . blackList ;
294
- }
295
- if ( ( ZoneAwareError as any ) [ stackRewrite ] && zoneAwareFrame1 &&
296
- zoneAwareFrame1WithoutNew ) {
297
- break ;
298
- }
299
- if ( fnName . indexOf ( 'runGuarded' ) !== - 1 ) {
300
- runGuardedFrame = true ;
301
- } else if ( fnName . indexOf ( 'runTask' ) !== - 1 ) {
302
- runTaskFrame = true ;
303
- } else if ( fnName . indexOf ( 'run' ) !== - 1 ) {
304
- runFrame = true ;
305
- } else {
306
- frameType = FrameType . blackList ;
307
- }
308
- blackListedStackFrames [ frame ] = frameType ;
309
- // Once we find all of the frames we can stop looking.
310
- if ( runFrame && runGuardedFrame && runTaskFrame ) {
311
- ( ZoneAwareError as any ) [ stackRewrite ] = true ;
312
- break ;
268
+ onHandleError : function (
269
+ parentZD : ZoneDelegate , current : Zone , target : Zone , error : any ) : boolean {
270
+ if ( error . originalStack && Error === ZoneAwareError ) {
271
+ let frames = error . originalStack . split ( / \n / ) ;
272
+ let runFrame = false , runGuardedFrame = false , runTaskFrame = false ;
273
+ while ( frames . length ) {
274
+ let frame = frames . shift ( ) ;
275
+ // On safari it is possible to have stack frame with no line number.
276
+ // This check makes sure that we don't filter frames on name only (must have
277
+ // line number)
278
+ if ( / : \d + : \d + / . test ( frame ) ) {
279
+ // Get rid of the path so that we don't accidentally find function name in path.
280
+ // In chrome the separator is `(` and `@` in FF and safari
281
+ // Chrome: at Zone.run (zone.js:100)
282
+ // Chrome: at Zone.run (http://localhost:9876/base/build/lib/zone.js:100:24)
283
+ // FireFox: Zone.prototype.run@http ://localhost:9876/base/build/lib/zone.js:101:24
284
+ // Safari: run@http ://localhost:9876/base/build/lib/zone.js:101:24
285
+ let fnName : string = frame . split ( '(' ) [ 0 ] . split ( '@' ) [ 0 ] ;
286
+ let frameType = FrameType . transition ;
287
+ if ( fnName . indexOf ( 'ZoneAwareError' ) !== - 1 ) {
288
+ if ( fnName . indexOf ( 'new ZoneAwareError' ) !== - 1 ) {
289
+ zoneAwareFrame1 = frame ;
290
+ zoneAwareFrame2 = frame . replace ( 'new ZoneAwareError' , 'new Error.ZoneAwareError' ) ;
291
+ } else {
292
+ zoneAwareFrame1WithoutNew = frame ;
293
+ zoneAwareFrame2WithoutNew = frame . replace ( 'Error.' , '' ) ;
294
+ if ( frame . indexOf ( 'Error.ZoneAwareError' ) === - 1 ) {
295
+ zoneAwareFrame3WithoutNew =
296
+ frame . replace ( 'ZoneAwareError' , 'Error.ZoneAwareError' ) ;
313
297
}
314
298
}
299
+ blackListedStackFrames [ zoneAwareFrame2 ] = FrameType . blackList ;
300
+ }
301
+ if ( fnName . indexOf ( 'runGuarded' ) !== - 1 ) {
302
+ runGuardedFrame = true ;
303
+ } else if ( fnName . indexOf ( 'runTask' ) !== - 1 ) {
304
+ runTaskFrame = true ;
305
+ } else if ( fnName . indexOf ( 'run' ) !== - 1 ) {
306
+ runFrame = true ;
307
+ } else {
308
+ frameType = FrameType . blackList ;
309
+ }
310
+ blackListedStackFrames [ frame ] = frameType ;
311
+ // Once we find all of the frames we can stop looking.
312
+ if ( runFrame && runGuardedFrame && runTaskFrame ) {
313
+ ( ZoneAwareError as any ) [ stackRewrite ] = true ;
314
+ break ;
315
315
}
316
316
}
317
- return false ;
318
317
}
318
+ }
319
+ return false ;
320
+ }
319
321
} ) as Zone ;
320
322
// carefully constructor a stack frame which contains all of the frames of interest which
321
323
// need to be detected and blacklisted.
@@ -395,5 +397,6 @@ Zone.__load_patch('Error', (global: any, Zone: ZoneType, api: _ZonePrivate) => {
395
397
console . log ( 'zoneAwareFrame2' , zoneAwareFrame2 ) ;
396
398
console . log ( 'zoneAwareFrame1WithoutNew' , zoneAwareFrame1WithoutNew ) ;
397
399
console . log ( 'zoneAwareFrame2WithoutNew' , zoneAwareFrame2WithoutNew ) ;
400
+ console . log ( 'zoneAwareFrame3WithoutNew' , zoneAwareFrame3WithoutNew ) ;
398
401
Error . stackTraceLimit = originalStackTraceLimit ;
399
402
} ) ;
0 commit comments