Skip to content

Commit 2f6794c

Browse files
author
Perki
committed
Slighty better error handling on getEventsStreamed
1 parent 55b04b5 commit 2f6794c

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

components/pryv/src/lib/getEventStreamed.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ async function getEventStreamed (conn, queryParam, parser) {
5959
}
6060

6161
if (errResult) {
62-
throw new Error(errResult);
62+
throw new Error(errResult?.message + ' ' + errResult?.rawResponse);
6363
}
6464

6565
// We're done!

components/pryv/test/Connection.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,21 @@ describe('[CONX] Connection', () => {
359359
expect(eventsCount).to.equal(res.eventsCount);
360360
});
361361

362+
it('[CSNY] streaming with roneous query params', async () => {
363+
const queryParams = { fromTime: 0, toTime: Date.now() / 1000, limit: 10000, types: ['note/txt'], streams: ['bogus', 'bogus2'] };
364+
let eventsCount = 0;
365+
function forEachEvent (event) {
366+
eventsCount++;
367+
}
368+
try {
369+
const res = await conn.getEventsStreamed(queryParams, forEachEvent);
370+
expect(eventsCount).to.equal(res.eventsCount);
371+
} catch (e) {
372+
return;
373+
}
374+
throw new Error('Should fail');
375+
});
376+
362377
it('[CSNB] streaming includesDeletion', async () => {
363378
const queryParams = { fromTime: 0, toTime: now, limit: 10000, includeDeletions: true, modifiedSince: 0, state: 'all' };
364379
let eventsCount = 0;

0 commit comments

Comments
 (0)