From 1cd81cd8fe949f9b185a252aa38a3a9cd6c727d5 Mon Sep 17 00:00:00 2001 From: Matt Robenolt Date: Wed, 28 Mar 2012 20:47:47 -0700 Subject: [PATCH] A little bit of cleaning up --- lib/parsers.js | 7 +++++-- lib/utils.js | 8 ++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/parsers.js b/lib/parsers.js index 1128aaf44a44..1de4f1210a1b 100644 --- a/lib/parsers.js +++ b/lib/parsers.js @@ -1,4 +1,4 @@ -var utils = require('./utils') +var utils = require('./utils'), url = require('url'); module.exports.parseText = function parseText(message, kwargs) { @@ -17,7 +17,10 @@ module.exports.parseError = function parseError(err, kwargs, cb) { kwargs['sentry.interfaces.Exception'] = {type:err.name, value:err.message}; if(frames) { kwargs['sentry.interfaces.Stacktrace'] = {frames:frames}; - kwargs['culprit'] = (frames[0].filename || 'unknown file').replace(process.cwd()+'/', '')+':'+(frames[0]['function'] || 'unknown function'); + kwargs['culprit'] = [ + (frames[0].filename || 'unknown file').replace(process.cwd()+'/', ''), + (frames[0]['function'] || 'unknown function') + ].join(':'); } if(err) { kwargs['sentry.interfaces.Message'] = { diff --git a/lib/utils.js b/lib/utils.js index 4c627b868540..365fb2b2684d 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -101,14 +101,18 @@ module.exports.parseStackBetter = function parseStackBetter(err, cb) { module.exports.parseStack = function parseStack(stack, cb) { try { // grab all lines except the first - var lines = stack.split('\n').slice(1), callbacks=lines.length, frames=[], cache={}; + var lines = stack.split('\n').slice(1), + callbacks=lines.length, + frames=[], + cache={}; if(lines.length === 0) { throw new Error('No lines to parse!'); } lines.forEach(function(line, index) { - var data = line.match(/^\s*at (?:(.+(?: \[\w\s+\])?) )?\(?(.+?)(?::(\d+):(\d+))?\)?$/).slice(1), + var pattern = /^\s*at (?:(.+(?: \[\w\s+\])?) )?\(?(.+?)(?::(\d+):(\d+))?\)?$/, + data = line.match(pattern).slice(1), frame = { filename: data[1], lineno: ~~data[2]