Skip to content

Commit 3843057

Browse files
Simplified code for Chrome. Reworked code for IE10.
1 parent b8695e6 commit 3843057

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

stacktrace.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,13 @@
143143
* @return Array<String> of function calls, files and line numbers
144144
*/
145145
chrome: function(e) {
146-
var stack = (e.stack + '\n')
147-
.replace(/^\S[^\(]+?[\n$]/gm, '') // remove first line
146+
return (e.stack + '\n')
148147
.replace(/^\s+(at eval )?at\s+/gm, '') // remove 'at' and indentation
149148
.replace(/^([^\(]+?)([\n$])/gm, '{anonymous}() ($1)$2')
150149
.replace(/^Object.<anonymous>\s*\(([^\)]+)\)/gm, '{anonymous}() ($1)')
151150
.replace(/^(.+) \((.+)\)$/gm, '$1@$2')
152-
.split('\n');
153-
stack.pop();
154-
return stack;
151+
.split('\n')
152+
.slice(1, -1);
155153
},
156154

157155
/**
@@ -174,11 +172,12 @@
174172
* @return Array<String> of function calls, files and line numbers
175173
*/
176174
ie: function(e) {
177-
var lineRE = /^.*at (\w+) \(([^\)]+)\)$/gm;
178-
return e.stack.replace(/at Anonymous function /gm, '{anonymous}()@')
179-
.replace(/^(?=\w+Error\:).*$\n/m, '')
180-
.replace(lineRE, '$1@$2')
181-
.split('\n');
175+
return e.stack
176+
.replace(/^\s*at\s+(.*)$/gm, '$1')
177+
.replace(/^Anonymous function\s+/gm, '{anonymous}() ')
178+
.replace(/^(.+)\s+\((.+)\)$/gm, '$1@$2')
179+
.split('\n')
180+
.slice(1);
182181
},
183182

184183
/**

0 commit comments

Comments
 (0)