@@ -7,7 +7,8 @@ var TraceKit = {
77 remoteFetching : false ,
88 collectWindowErrors : true ,
99 // 3 lines before, the offending line, 3 lines after
10- linesOfContext : 7
10+ linesOfContext : 7 ,
11+ debug : false
1112} ;
1213
1314// global reference to slice
@@ -305,8 +306,7 @@ TraceKit.report = (function reportModuleWrapper() {
305306 *
306307 */
307308TraceKit . computeStackTrace = ( function computeStackTraceWrapper ( ) {
308- var debug = false ,
309- sourceCache = { } ;
309+ var sourceCache = { } ;
310310
311311 /**
312312 * Attempts to retrieve source code via XMLHttpRequest, which is used
@@ -615,11 +615,9 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
615615 * @return {?Object.<string, *> } Stack trace information.
616616 */
617617 function computeStackTraceFromStackProp ( ex ) {
618- if ( ! ex . stack ) {
619- return null ;
620- }
618+ if ( isUndefined ( ex . stack ) || ! ex . stack ) return ;
621619
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,
623621 gecko = / ^ \s * ( .* ?) (?: \( ( .* ?) \) ) ? @ ( (?: f i l e | h t t p s ? | c h r o m e ) .* ?) : ( \d + ) (?: : ( \d + ) ) ? \s * $ / i,
624622 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,
625623 lines = ex . stack . split ( '\n' ) ,
@@ -645,12 +643,12 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
645643 'column' : parts [ 4 ] ? + parts [ 4 ] : null
646644 } ;
647645 } 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+ } ;
654652 } else {
655653 continue ;
656654 }
@@ -698,6 +696,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
698696 // else to it because Opera is not very good at providing it
699697 // reliably in other circumstances.
700698 var stacktrace = ex . stacktrace ;
699+ if ( isUndefined ( ex . stacktrace ) || ! ex . stacktrace ) return ;
701700
702701 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,
703702 lines = stacktrace . split ( '\n' ) ,
@@ -1010,7 +1009,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
10101009 return stack ;
10111010 }
10121011 } catch ( e ) {
1013- if ( debug ) {
1012+ if ( TraceKit . debug ) {
10141013 throw e ;
10151014 }
10161015 }
@@ -1021,7 +1020,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
10211020 return stack ;
10221021 }
10231022 } catch ( e ) {
1024- if ( debug ) {
1023+ if ( TraceKit . debug ) {
10251024 throw e ;
10261025 }
10271026 }
@@ -1032,7 +1031,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
10321031 return stack ;
10331032 }
10341033 } catch ( e ) {
1035- if ( debug ) {
1034+ if ( TraceKit . debug ) {
10361035 throw e ;
10371036 }
10381037 }
@@ -1043,12 +1042,16 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
10431042 return stack ;
10441043 }
10451044 } catch ( e ) {
1046- if ( debug ) {
1045+ if ( TraceKit . debug ) {
10471046 throw e ;
10481047 }
10491048 }
10501049
1051- return { } ;
1050+ return {
1051+ 'name' : ex . name ,
1052+ 'message' : lines [ 0 ] ,
1053+ 'url' : document . location . href ,
1054+ } ;
10521055 }
10531056
10541057 computeStackTrace . augmentStackTraceWithInitialElement = augmentStackTraceWithInitialElement ;
0 commit comments