@@ -1423,7 +1423,9 @@ const Zone: ZoneType = (function(global: any) {
14231423
14241424 if ( NativeError . hasOwnProperty ( 'captureStackTrace' ) ) {
14251425 Object . defineProperty ( ZoneAwareError , 'captureStackTrace' , {
1426- value : function ( targetObject : Object , constructorOpt ?: Function ) {
1426+ // add named function here because we need to remove this
1427+ // stack frame when prepareStackTrace below
1428+ value : function zoneCaptureStackTrace ( targetObject : Object , constructorOpt ?: Function ) {
14271429 NativeError . captureStackTrace ( targetObject , constructorOpt ) ;
14281430 }
14291431 } ) ;
@@ -1434,7 +1436,23 @@ const Zone: ZoneType = (function(global: any) {
14341436 return NativeError . prepareStackTrace ;
14351437 } ,
14361438 set : function ( value ) {
1437- return NativeError . prepareStackTrace = value ;
1439+ if ( ! value || typeof value !== 'function' ) {
1440+ return NativeError . prepareStackTrace = value ;
1441+ }
1442+ return NativeError . prepareStackTrace = function ( error , structuredStackTrace ) {
1443+ // remove additional stack information from ZoneAwareError.captureStackTrace
1444+ if ( structuredStackTrace ) {
1445+ for ( let i = 0 ; i < structuredStackTrace . length ; i ++ ) {
1446+ const st = structuredStackTrace [ i ] ;
1447+ // remove the first function which name is value
1448+ if ( st . getFunctionName ( ) === 'zoneCaptureStackTrace' ) {
1449+ structuredStackTrace . splice ( i , 1 ) ;
1450+ break ;
1451+ }
1452+ }
1453+ }
1454+ return value . apply ( this , [ error , structuredStackTrace ] ) ;
1455+ } ;
14381456 }
14391457 } ) ;
14401458
0 commit comments