Skip to content

Commit 64ca528

Browse files
committed
Standard error messages
This switches to the standard upstream label format of "Type: Value". It also removes the seemingly unuseful " at [lineno]" clause.
1 parent 5f1dc58 commit 64ca528

File tree

2 files changed

+19
-57
lines changed

2 files changed

+19
-57
lines changed

src/raven.js

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -614,20 +614,15 @@ function extractContextFromFrame(frame) {
614614
}
615615

616616
function processException(type, message, fileurl, lineno, frames, options) {
617-
var stacktrace, label, i;
617+
var stacktrace, i, fullMessage;
618618

619-
// In some instances message is not actually a string, no idea why,
620-
// so we want to always coerce it to one.
621-
message += '';
619+
if (globalOptions.ignoreErrors.test(message)) return;
622620

623-
// Sometimes an exception is getting logged in Sentry as
624-
// <no message value>
625-
// This can only mean that the message was falsey since this value
626-
// is hardcoded into Sentry itself.
627-
// At this point, if the message is falsey, we bail since it's useless
628-
if (type === 'Error' && !message) return;
621+
message += '';
622+
message = truncate(message, globalOptions.maxMessageLength);
629623

630-
if (globalOptions.ignoreErrors.test(message)) return;
624+
fullMessage = type + ': ' + message;
625+
fullMessage = truncate(fullMessage, globalOptions.maxMessageLength);
631626

632627
if (frames && frames.length) {
633628
fileurl = frames[0].filename || fileurl;
@@ -645,14 +640,9 @@ function processException(type, message, fileurl, lineno, frames, options) {
645640
};
646641
}
647642

648-
// Truncate the message to a max of characters
649-
message = truncate(message, globalOptions.maxMessageLength);
650-
651643
if (globalOptions.ignoreUrls && globalOptions.ignoreUrls.test(fileurl)) return;
652644
if (globalOptions.whitelistUrls && !globalOptions.whitelistUrls.test(fileurl)) return;
653645

654-
label = lineno ? message + ' at ' + lineno : message;
655-
656646
// Fire away!
657647
send(
658648
objectMerge({
@@ -664,7 +654,7 @@ function processException(type, message, fileurl, lineno, frames, options) {
664654
// sentry.interfaces.Stacktrace
665655
stacktrace: stacktrace,
666656
culprit: fileurl,
667-
message: label
657+
message: fullMessage
668658
}, options)
669659
);
670660
}
@@ -713,12 +703,11 @@ function send(data) {
713703
var baseData = {
714704
project: globalProject,
715705
logger: globalOptions.logger,
716-
platform: 'javascript',
717-
// sentry.interfaces.Http
706+
platform: 'javascript'
718707
};
719708
var http = getHttpData();
720709
if (http) {
721-
baseData.http = http;
710+
baseData.request = http;
722711
}
723712

724713
data = objectMerge(baseData, data);

test/raven.test.js

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ describe('globals', function() {
689689
frames: framesFlipped
690690
},
691691
culprit: 'http://example.com/file1.js',
692-
message: 'lol at 10'
692+
message: 'Error: lol'
693693
}]);
694694

695695
processException('Error', 'lol', '', 10, frames.slice(0), {});
@@ -702,7 +702,7 @@ describe('globals', function() {
702702
frames: framesFlipped
703703
},
704704
culprit: 'http://example.com/file1.js',
705-
message: 'lol at 10'
705+
message: 'Error: lol'
706706
}]);
707707

708708
processException('Error', 'lol', '', 10, frames.slice(0), {extra: 'awesome'});
@@ -715,7 +715,7 @@ describe('globals', function() {
715715
frames: framesFlipped
716716
},
717717
culprit: 'http://example.com/file1.js',
718-
message: 'lol at 10',
718+
message: 'Error: lol',
719719
extra: 'awesome'
720720
}]);
721721
});
@@ -737,7 +737,7 @@ describe('globals', function() {
737737
}]
738738
},
739739
culprit: 'http://example.com/override.js',
740-
message: 'lol at 10'
740+
message: 'Error: lol'
741741
}]);
742742

743743
processException('Error', 'lol', 'http://example.com/override.js', 10, [], {});
@@ -754,7 +754,7 @@ describe('globals', function() {
754754
}]
755755
},
756756
culprit: 'http://example.com/override.js',
757-
message: 'lol at 10'
757+
message: 'Error: lol',
758758
}]);
759759

760760
processException('Error', 'lol', 'http://example.com/override.js', 10, [], {extra: 'awesome'});
@@ -771,21 +771,11 @@ describe('globals', function() {
771771
}]
772772
},
773773
culprit: 'http://example.com/override.js',
774-
message: 'lol at 10',
774+
message: 'Error: lol',
775775
extra: 'awesome'
776776
}]);
777777
});
778778

779-
it('should ignored falsey messages', function() {
780-
this.sinon.stub(window, 'send');
781-
782-
processException('Error', '', 'http://example.com', []);
783-
assert.isFalse(window.send.called);
784-
785-
processException('TypeError', '', 'http://example.com', []);
786-
assert.isTrue(window.send.called);
787-
});
788-
789779
it('should not blow up with `undefined` message', function() {
790780
this.sinon.stub(window, 'send');
791781

@@ -796,36 +786,19 @@ describe('globals', function() {
796786
it('should truncate messages to the specified length', function() {
797787
this.sinon.stub(window, 'send');
798788

799-
processException('TypeError', new Array(500).join('a'), 'http://example.com', []);
800-
assert.deepEqual(window.send.lastCall.args, [{
801-
message: new Array(101).join('a')+'\u2026 at ',
802-
exception: {
803-
type: 'TypeError',
804-
value: new Array(101).join('a')+'\u2026'
805-
},
806-
stacktrace: {
807-
frames: [{
808-
filename: 'http://example.com',
809-
lineno: [],
810-
in_app: true
811-
}]
812-
},
813-
culprit: 'http://example.com',
814-
}]);
815-
816789
globalOptions.maxMessageLength = 150;
817790

818-
processException('TypeError', new Array(500).join('a'), 'http://example.com', []);
791+
processException('TypeError', new Array(500).join('a'), 'http://example.com', 34);
819792
assert.deepEqual(window.send.lastCall.args, [{
820-
message: new Array(151).join('a')+'\u2026 at ',
793+
message: 'TypeError: ' + new Array(140).join('a')+'\u2026',
821794
exception: {
822795
type: 'TypeError',
823796
value: new Array(151).join('a')+'\u2026'
824797
},
825798
stacktrace: {
826799
frames: [{
827800
filename: 'http://example.com',
828-
lineno: [],
801+
lineno: 34,
829802
in_app: true
830803
}]
831804
},
@@ -1204,7 +1177,7 @@ describe('globals', function() {
12041177
}]
12051178
},
12061179
culprit: 'http://example.com',
1207-
message: 'crap at 10',
1180+
message: 'Error: crap',
12081181
foo: 'bar'
12091182
}]);
12101183
*/

0 commit comments

Comments
 (0)