Skip to content

Commit

Permalink
fix: pullMessages error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
agsh committed Feb 27, 2024
1 parent 395ade0 commit 768bc8b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ test.js
cam_tests
experiments
docs
.nyc_output/
2 changes: 2 additions & 0 deletions lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ module.exports = function(Cam) {
} catch (e) {
if (callback && callback.call) {
callback.call(this, new Error('You should create pull-point subscription first!'));
} else {
throw new Error('You should create pull-point subscription first!');
}
return;
}
Expand Down
7 changes: 5 additions & 2 deletions test/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ describe('Events', () => {
});
it('should throws an error in PullMessages method when no pull-point subscription exists', (done) => {
assert.throws(() => {
cam.pullMessages({}, () => {});
cam.pullMessages({});
});
cam.pullMessages({}, (err) => {
assert.notEqual(err, null);
done();
});
done();
});
it('should create PullPointSubscription', (done) => {
cam.createPullPointSubscription((err, data) => {
Expand Down

0 comments on commit 768bc8b

Please sign in to comment.