Skip to content

Commit 091deb2

Browse files
author
Eric Wendelin
committed
Parse anonymous functions correctly in Opera 11.
1 parent 6622026 commit 091deb2

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

error-stack-parser.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,13 @@
206206
var tokens = line.split('@');
207207
var locationParts = this.extractLocation(tokens.pop());
208208
var functionCall = (tokens.shift() || '');
209-
var functionName = functionCall.replace(/<anonymous function: (\w+)>/, '$1').replace(/\([^\)]*\)/, '') || undefined;
210-
var argsRaw = functionCall.replace(/^[^\(]+\(([^\)]*)\)$/, '$1') || undefined;
209+
var functionName = functionCall
210+
.replace(/<anonymous function(: (\w+))?>/, '$2')
211+
.replace(/\([^\)]*\)/g, '') || undefined;
212+
var argsRaw;
213+
if (functionCall.match(/\(([^\)]*)\)/)) {
214+
argsRaw = functionCall.replace(/^[^\(]+\(([^\)]*)\)$/, '$1');
215+
}
211216
var args = (argsRaw === undefined || argsRaw === '[arguments not available]') ? undefined : argsRaw.split(',');
212217
return new StackFrame(functionName, args, locationParts[0], locationParts[1], locationParts[2]);
213218
}.bind(this));

spec/fixtures/captured-errors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ CapturedExceptions.OPERA_11 = {
115115
stack: "<anonymous function: run>([arguments not available])@http://path/to/file.js:27\n" +
116116
"bar([arguments not available])@http://domain.com:1234/path/to/file.js:18\n" +
117117
"foo([arguments not available])@http://domain.com:1234/path/to/file.js:11\n" +
118-
"@http://path/to/file.js:15",
118+
"<anonymous function>@http://path/to/file.js:15",
119119
stacktrace: "Error thrown at line 42, column 12 in <anonymous function: createException>() in http://path/to/file.js:\n" +
120120
" this.undef();\n" +
121121
"called from line 27, column 8 in <anonymous function: run>(ex) in http://path/to/file.js:\n" +

0 commit comments

Comments
 (0)