Skip to content

Commit f34d0ea

Browse files
committed
Merge pull request #538 from getsentry/no-undefined-msg
Don't include error name as part of msg if it is falsy
2 parents 6e1921a + 8126bcd commit f34d0ea

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/raven.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ Raven.prototype = {
855855
message += '';
856856
message = truncate(message, this._globalOptions.maxMessageLength);
857857

858-
fullMessage = type + ': ' + message;
858+
fullMessage = (type ? type + ': ' : '') + message;
859859
fullMessage = truncate(fullMessage, this._globalOptions.maxMessageLength);
860860

861861
if (frames && frames.length) {

test/raven.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,13 @@ describe('globals', function() {
695695
Raven._processException('TypeError', undefined, 'http://example.com', []);
696696
assert.isTrue(Raven._send.called);
697697
});
698+
699+
it('should omit error name as part of message if error name is undefined/falsy', function () {
700+
this.sinon.stub(Raven, '_send');
701+
702+
Raven._processException(undefined, '\'foo\' is undefined', 'http://example.com', 10); // IE9 ReferenceError
703+
assert.deepEqual(Raven._send.lastCall.args[0].message, '\'foo\' is undefined');
704+
});
698705
});
699706

700707
describe('send', function() {

0 commit comments

Comments
 (0)