@@ -7,7 +7,8 @@ var TraceKit = {
7
7
remoteFetching : false ,
8
8
collectWindowErrors : true ,
9
9
// 3 lines before, the offending line, 3 lines after
10
- linesOfContext : 7
10
+ linesOfContext : 7 ,
11
+ debug : false
11
12
} ;
12
13
13
14
// global reference to slice
@@ -305,8 +306,7 @@ TraceKit.report = (function reportModuleWrapper() {
305
306
*
306
307
*/
307
308
TraceKit . computeStackTrace = ( function computeStackTraceWrapper ( ) {
308
- var debug = false ,
309
- sourceCache = { } ;
309
+ var sourceCache = { } ;
310
310
311
311
/**
312
312
* Attempts to retrieve source code via XMLHttpRequest, which is used
@@ -615,11 +615,9 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
615
615
* @return {?Object.<string, *> } Stack trace information.
616
616
*/
617
617
function computeStackTraceFromStackProp ( ex ) {
618
- if ( ! ex . stack ) {
619
- return null ;
620
- }
618
+ if ( isUndefined ( ex . stack ) || ! ex . stack ) return ;
621
619
622
- var chrome = / ^ \s * a t ( .* ?) ? \( ? ( (?: f i l e | h t t p s ? | c h r o m e - e x t e n s i o n ) : .* ?) : ( \d + ) (?: : ( \d + ) ) ? \) ? \s * $ / i,
620
+ var chrome = / ^ \s * a t ( .* ?) ? \( ? ( (?: (?: f i l e | h t t p s ? | c h r o m e - e x t e n s i o n ) : .* ?) | < a n o n y m o u s > ) : ( \d + ) (?: : ( \d + ) ) ? \) ? \s * $ / i,
623
621
gecko = / ^ \s * ( .* ?) (?: \( ( .* ?) \) ) ? @ ( (?: f i l e | h t t p s ? | c h r o m e ) .* ?) : ( \d + ) (?: : ( \d + ) ) ? \s * $ / i,
624
622
winjs = / ^ \s * a t (?: ( (?: \[ o b j e c t o b j e c t \] ) ? .+ ) ) ? \( ? ( (?: m s - a p p x | h t t p | h t t p s ) : .* ?) : ( \d + ) (?: : ( \d + ) ) ? \) ? \s * $ / i,
625
623
lines = ex . stack . split ( '\n' ) ,
@@ -645,12 +643,12 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
645
643
'column' : parts [ 4 ] ? + parts [ 4 ] : null
646
644
} ;
647
645
} else if ( ( parts = winjs . exec ( lines [ i ] ) ) ) {
648
- element = {
649
- 'url' : parts [ 2 ] ,
650
- 'func' : parts [ 1 ] || UNKNOWN_FUNCTION ,
651
- 'line' : + parts [ 3 ] ,
652
- 'column' : parts [ 4 ] ? + parts [ 4 ] : null
653
- } ;
646
+ element = {
647
+ 'url' : parts [ 2 ] ,
648
+ 'func' : parts [ 1 ] || UNKNOWN_FUNCTION ,
649
+ 'line' : + parts [ 3 ] ,
650
+ 'column' : parts [ 4 ] ? + parts [ 4 ] : null
651
+ } ;
654
652
} else {
655
653
continue ;
656
654
}
@@ -698,6 +696,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
698
696
// else to it because Opera is not very good at providing it
699
697
// reliably in other circumstances.
700
698
var stacktrace = ex . stacktrace ;
699
+ if ( isUndefined ( ex . stacktrace ) || ! ex . stacktrace ) return ;
701
700
702
701
var testRE = / l i n e ( \d + ) , c o l u m n ( \d + ) i n (?: < a n o n y m o u s f u n c t i o n : ( [ ^ > ] + ) > | ( [ ^ \) ] + ) ) \( ( .* ) \) i n ( .* ) : \s * $ / i,
703
702
lines = stacktrace . split ( '\n' ) ,
@@ -1010,7 +1009,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
1010
1009
return stack ;
1011
1010
}
1012
1011
} catch ( e ) {
1013
- if ( debug ) {
1012
+ if ( TraceKit . debug ) {
1014
1013
throw e ;
1015
1014
}
1016
1015
}
@@ -1021,7 +1020,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
1021
1020
return stack ;
1022
1021
}
1023
1022
} catch ( e ) {
1024
- if ( debug ) {
1023
+ if ( TraceKit . debug ) {
1025
1024
throw e ;
1026
1025
}
1027
1026
}
@@ -1032,7 +1031,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
1032
1031
return stack ;
1033
1032
}
1034
1033
} catch ( e ) {
1035
- if ( debug ) {
1034
+ if ( TraceKit . debug ) {
1036
1035
throw e ;
1037
1036
}
1038
1037
}
@@ -1043,12 +1042,16 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
1043
1042
return stack ;
1044
1043
}
1045
1044
} catch ( e ) {
1046
- if ( debug ) {
1045
+ if ( TraceKit . debug ) {
1047
1046
throw e ;
1048
1047
}
1049
1048
}
1050
1049
1051
- return { } ;
1050
+ return {
1051
+ 'name' : ex . name ,
1052
+ 'message' : lines [ 0 ] ,
1053
+ 'url' : document . location . href ,
1054
+ } ;
1052
1055
}
1053
1056
1054
1057
computeStackTrace . augmentStackTraceWithInitialElement = augmentStackTraceWithInitialElement ;
0 commit comments