Skip to content

Commit

Permalink
A little bit of cleaning up
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrobenolt committed Mar 29, 2012
1 parent 73015b4 commit 1cd81cd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 5 additions & 2 deletions lib/parsers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var utils = require('./utils')
var utils = require('./utils'),
url = require('url');

module.exports.parseText = function parseText(message, kwargs) {
Expand All @@ -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'] = {
Expand Down
8 changes: 6 additions & 2 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 1cd81cd

Please sign in to comment.