Skip to content

Commit 9b901a7

Browse files
committed
Merge pull request #224 from skovhus/script-error-filter
Updated ignore errors
2 parents c34acf7 + 7384ce4 commit 9b901a7

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

src/raven.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ var Raven = {
6868
globalOptions.ignoreErrors.push('Script error.');
6969
globalOptions.ignoreErrors.push('Script error');
7070

71+
// Other variants of external script errors:
72+
globalOptions.ignoreErrors.push('Javascript error: Script error on line 0');
73+
globalOptions.ignoreErrors.push('Javascript error: Script error. on line 0');
74+
7175
// join regexp rules into one big rule
7276
globalOptions.ignoreErrors = joinRegExp(globalOptions.ignoreErrors);
7377
globalOptions.ignoreUrls = globalOptions.ignoreUrls.length ? joinRegExp(globalOptions.ignoreUrls) : false;

test/raven.test.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ describe('TraceKit', function(){
8484
if (numDone == numReports) {
8585
done();
8686
}
87-
}
87+
};
8888
TraceKit.report.subscribe(subscriptionHandler);
8989

9090
// TraceKit.report always throws an exception in order to trigger
@@ -181,7 +181,7 @@ describe('globals', function() {
181181
assert.isTrue(isString(''));
182182
assert.isFalse(isString({}));
183183
assert.isFalse(isString(undefined));
184-
assert.isFalse(isString(function(){}))
184+
assert.isFalse(isString(function(){}));
185185
});
186186
});
187187

@@ -1080,6 +1080,17 @@ describe('Raven (public API)', function() {
10801080
});
10811081
});
10821082

1083+
describe('ignore errors', function() {
1084+
it('should install default ignore errors', function() {
1085+
Raven.config('//abc@example.com/2');
1086+
1087+
assert.isTrue(globalOptions.ignoreErrors.test('Script error'), 'it should install "Script error" by default');
1088+
assert.isTrue(globalOptions.ignoreErrors.test('Script error.'), 'it should install "Script error." by default');
1089+
assert.isTrue(globalOptions.ignoreErrors.test('Javascript error: Script error on line 0'), 'it should install "Javascript error: Script error on line 0" by default');
1090+
assert.isTrue(globalOptions.ignoreErrors.test('Javascript error: Script error. on line 0'), 'it should install "Javascript error: Script error. on line 0" by default');
1091+
});
1092+
});
1093+
10831094
describe('callback function', function() {
10841095
it('should callback a function if it is global', function() {
10851096
window.RavenConfig = {
@@ -1094,8 +1105,7 @@ describe('Raven (public API)', function() {
10941105

10951106
assert.equal(globalKey, 'random');
10961107
assert.equal(globalServer, 'http://some.other.server:80/api/2/store/');
1097-
assert.isTrue(globalOptions.ignoreErrors.test('Script error'), 'it should install "Script error" by default');
1098-
assert.isTrue(globalOptions.ignoreErrors.test('Script error.'), 'it should install "Script error." by default');
1108+
10991109
assert.equal(globalOptions.some, 'config');
11001110
assert.equal(globalProject, '2');
11011111

@@ -1111,8 +1121,6 @@ describe('Raven (public API)', function() {
11111121
assert.equal(Raven, Raven.config(SENTRY_DSN, {foo: 'bar'}), 'it should return Raven');
11121122
assert.equal(globalKey, 'abc');
11131123
assert.equal(globalServer, 'http://example.com:80/api/2/store/');
1114-
assert.isTrue(globalOptions.ignoreErrors.test('Script error'), 'it should install "Script error" by default');
1115-
assert.isTrue(globalOptions.ignoreErrors.test('Script error.'), 'it should install "Script error." by default');
11161124
assert.equal(globalOptions.foo, 'bar');
11171125
assert.equal(globalProject, '2');
11181126
assert.isTrue(isSetup());
@@ -1122,8 +1130,6 @@ describe('Raven (public API)', function() {
11221130
Raven.config('//abc@example.com/2');
11231131
assert.equal(globalKey, 'abc');
11241132
assert.equal(globalServer, '//example.com/api/2/store/');
1125-
assert.isTrue(globalOptions.ignoreErrors.test('Script error'), 'it should install "Script error" by default');
1126-
assert.isTrue(globalOptions.ignoreErrors.test('Script error.'), 'it should install "Script error." by default');
11271133
assert.equal(globalProject, '2');
11281134
assert.isTrue(isSetup());
11291135
});

0 commit comments

Comments
 (0)