Skip to content

Commit

Permalink
MLIBZ-2323: Don't swallow error when using observable (#302)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasconner committed May 31, 2018
1 parent cbdedbe commit c0889a0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/core/datastore/cachestore.spec.js
Expand Up @@ -109,6 +109,25 @@ describe('CacheStore', () => {
});
});

it('should throw an error if trying to access a property on undefined', (done) => {
const store = new CacheStore(collection);
const onNextSpy = expect.createSpy();

store.find()
.subscribe((entities) => {
return entities[0].name;
}, (error) => {
try {
expect(error).toBeA(TypeError);
done();
} catch (e) {
done(e);
}
}, () => {
done(new Error('This test should fail.'));
});
});

it('should return the entities', (done) => {
const entity1 = { _id: randomString() };
const entity2 = { _id: randomString() };
Expand Down
2 changes: 1 addition & 1 deletion src/core/observable.js
Expand Up @@ -128,7 +128,7 @@ class SafeSubscriber extends Subscriber {
try {
fn.call(this._context, value);
} catch (err) {
this.unsubscribe();
this.error(err);
throw err;
}
}
Expand Down

0 comments on commit c0889a0

Please sign in to comment.