A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/stacktracejs/error-stack-parser/commit/1c9261ac800e39e1ee7a8369919c7e17f607af55 below:

Merge pull request #66 from Aleksey28/parse-file-name-for-node · stacktracejs/error-stack-parser@1c9261a · GitHub

File tree Expand file treeCollapse file tree 3 files changed

+13

-9

lines changed

Filter options

Expand file treeCollapse file tree 3 files changed

+13

-9

lines changed Original file line number Diff line number Diff line change

@@ -56,21 +56,21 @@

56 56

return filtered.map(function(line) {

57 57

if (line.indexOf('(eval ') > -1) {

58 58

// Throw away eval information until we implement stacktrace.js/stackframe#8

59 -

line = line.replace(/eval code/g, 'eval').replace(/(\(eval at [^()]*)|(\),.*$)/g, '');

59 +

line = line.replace(/eval code/g, 'eval').replace(/(\(eval at [^()]*)|(,.*$)/g, '');

60 60

}

61 -

var sanitizedLine = line.replace(/^\s+/, '').replace(/\(eval code/g, '(');

61 +

var sanitizedLine = line.replace(/^\s+/, '').replace(/\(eval code/g, '(').replace(/^.*?\s+/, '');

62 62 63 63

// capture and preseve the parenthesized location "(/foo/my bar.js:12:87)" in

64 64

// case it has spaces in it, as the string is split on \s+ later on

65 -

var location = sanitizedLine.match(/ (\((.+):(\d+):(\d+)\)$)/);

65 +

var location = sanitizedLine.match(/ (\(.+\)$)/);

66 66 67 67

// remove the parenthesized location from the line, if it was matched

68 68

sanitizedLine = location ? sanitizedLine.replace(location[0], '') : sanitizedLine;

69 69 70 -

var tokens = sanitizedLine.split(/\s+/).slice(1);

71 -

// if a location was matched, pass it to extractLocation() otherwise pop the last token

72 -

var locationParts = this.extractLocation(location ? location[1] : tokens.pop());

73 -

var functionName = tokens.join(' ') || undefined;

70 +

// if a location was matched, pass it to extractLocation() otherwise pass all sanitizedLine

71 +

// because this line doesn't have function name

72 +

var locationParts = this.extractLocation(location ? location[1] : sanitizedLine);

73 +

var functionName = location && sanitizedLine || undefined;

74 74

var fileName = ['eval', '<anonymous>'].indexOf(locationParts[0]) > -1 ? undefined : locationParts[0];

75 75 76 76

return new StackFrame({

Original file line number Diff line number Diff line change

@@ -225,10 +225,13 @@ describe('ErrorStackParser', function() {

225 225 226 226

it('should handle spaces in Node.js stacks', function() {

227 227

var stackframes = unit.parse(CapturedExceptions.NODE_WITH_SPACES);

228 -

expect(stackframes.length).toBe(7);

228 +

expect(stackframes.length).toBe(8);

229 229

expect(stackframes[0].fileName).toEqual('/var/app/scratch/my project/index.js');

230 230

expect(stackframes[0].lineNumber).toBe(2);

231 231

expect(stackframes[0].columnNumber).toBe(9);

232 +

expect(stackframes[1].fileName).toEqual('/var/app/scratch/my project/index.js');

233 +

expect(stackframes[1].lineNumber).toBe(2);

234 +

expect(stackframes[1].columnNumber).toBe(9);

232 235

});

233 236

});

234 237

});

Original file line number Diff line number Diff line change

@@ -387,7 +387,8 @@ CapturedExceptions.EDGE_20_NESTED_EVAL = {

387 387

CapturedExceptions.NODE_WITH_SPACES = {

388 388

name: 'Error',

389 389

message: '',

390 -

stack: 'Error\n at Object.<anonymous> ' +

390 +

stack: 'Error\n at /var/app/scratch/my '+

391 +

'project/index.js:2:9\n at Object.<anonymous> ' +

391 392

'(/var/app/scratch/my ' +

392 393

'project/index.js:2:9)\n at Module._compile ' +

393 394

'(internal/modules/cjs/loader.js:774:30)\n at ' +

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4