Skip to content

Commit 33d97df

Browse files
authored
Merge pull request #60 from segmentio/throw-errors
Don't swallow integration errors
2 parents 4ed7f55 + 5f7c334 commit 33d97df

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

lib/protos.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -174,16 +174,9 @@ exports.invoke = function(method) {
174174
if (!this[method]) return;
175175
var args = Array.prototype.slice.call(arguments, 1);
176176
if (!this._ready) return this.queue(method, args);
177-
var ret;
178177

179-
try {
180-
this.debug('%s with %o', method, args);
181-
ret = this[method].apply(this, args);
182-
} catch (e) {
183-
this.debug('error %o calling %s with %o', e, method, args);
184-
}
185-
186-
return ret;
178+
this.debug('%s with %o', method, args);
179+
return this[method].apply(this, args);
187180
};
188181

189182
/**

test/index.test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,12 @@ describe('integration', function() {
292292
assert(integration.track.calledWith('event'));
293293
});
294294

295-
it('should catch errors when it calls', function() {
295+
it('should throw errors if the integration errors', function() {
296296
integration.emit('ready');
297297
integration.initialize();
298-
integration.invoke('page', 'name');
298+
assert['throws'](function() {
299+
integration.invoke('page', 'name');
300+
}, Error, 'Should not swallow exceptions');
299301
});
300302

301303
it('should return the returned value', function(done) {

0 commit comments

Comments
 (0)