@@ -15,7 +15,6 @@ var TraceKit = {
15
15
var _slice = [ ] . slice ;
16
16
var UNKNOWN_FUNCTION = '?' ;
17
17
18
-
19
18
/**
20
19
* TraceKit.wrap: Wrap any function in a TraceKit reporter
21
20
* Example: func = TraceKit.wrap(func);
@@ -35,6 +34,13 @@ TraceKit.wrap = function traceKitWrapper(func) {
35
34
return wrapped ;
36
35
} ;
37
36
37
+ function getLocationHref ( ) {
38
+ if ( typeof document === 'undefined' )
39
+ return '' ;
40
+
41
+ return document . location . href ;
42
+ } ;
43
+
38
44
/**
39
45
* TraceKit.report: cross-browser processing of unhandled exceptions
40
46
*
@@ -168,7 +174,7 @@ TraceKit.report = (function reportModuleWrapper() {
168
174
location . context = TraceKit . computeStackTrace . gatherContext ( location . url , location . line ) ;
169
175
stack = {
170
176
'message' : message ,
171
- 'url' : document . location . href ,
177
+ 'url' : getLocationHref ( ) ,
172
178
'stack' : [ location ]
173
179
} ;
174
180
notifyHandlers ( stack , true ) ;
@@ -512,6 +518,9 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
512
518
* the url, line, and column number of the defined function.
513
519
*/
514
520
function findSourceByFunctionBody ( func ) {
521
+ if ( typeof document === 'undefined' )
522
+ return ;
523
+
515
524
var urls = [ window . location . href ] ,
516
525
scripts = document . getElementsByTagName ( 'script' ) ,
517
526
body ,
@@ -680,7 +689,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
680
689
return {
681
690
'name' : ex . name ,
682
691
'message' : ex . message ,
683
- 'url' : document . location . href ,
692
+ 'url' : getLocationHref ( ) ,
684
693
'stack' : stack
685
694
} ;
686
695
}
@@ -737,7 +746,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
737
746
return {
738
747
'name' : ex . name ,
739
748
'message' : ex . message ,
740
- 'url' : document . location . href ,
749
+ 'url' : getLocationHref ( ) ,
741
750
'stack' : stack
742
751
} ;
743
752
}
@@ -847,7 +856,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
847
856
return {
848
857
'name' : ex . name ,
849
858
'message' : lines [ 0 ] ,
850
- 'url' : document . location . href ,
859
+ 'url' : getLocationHref ( ) ,
851
860
'stack' : stack
852
861
} ;
853
862
}
@@ -984,7 +993,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
984
993
var result = {
985
994
'name' : ex . name ,
986
995
'message' : ex . message ,
987
- 'url' : document . location . href ,
996
+ 'url' : getLocationHref ( ) ,
988
997
'stack' : stack
989
998
} ;
990
999
augmentStackTraceWithInitialElement ( result , ex . sourceURL || ex . fileName , ex . line || ex . lineNumber , ex . message || ex . description ) ;
@@ -1050,7 +1059,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
1050
1059
return {
1051
1060
'name' : ex . name ,
1052
1061
'message' : ex . message ,
1053
- 'url' : document . location . href ,
1062
+ 'url' : getLocationHref ( ) ,
1054
1063
} ;
1055
1064
}
1056
1065
0 commit comments