Skip to content

Commit

Permalink
Add error handling for single poll.
Browse files Browse the repository at this point in the history
  • Loading branch information
kinyoklion committed Sep 30, 2024
1 parent 11e430c commit df41f81
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions packages/sdk/browser/src/BrowserDataManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
BaseDataManager,
Configuration,
Context,
DataSourceErrorKind,
DataSourcePaths,
DataSourceState,
FlagManager,
Expand Down Expand Up @@ -83,10 +84,22 @@ export default class BrowserDataManager extends BaseDataManager {
try {
this.dataSourceStatusManager.requestStateUpdate(DataSourceState.Initializing);
const payload = await requestor.requestPayload();
const listeners = this.createStreamListeners(context, identifyResolve);
const putListener = listeners.get('put');
putListener!.processJson(putListener!.deserializeData(payload));
try {
const listeners = this.createStreamListeners(context, identifyResolve);
const putListener = listeners.get('put');
putListener!.processJson(putListener!.deserializeData(payload));
} catch (e: any) {
this.dataSourceStatusManager.reportError(
DataSourceErrorKind.InvalidData,
e.message ?? 'Could not parse poll response',
);
}
} catch (e: any) {
this.dataSourceStatusManager.reportError(
DataSourceErrorKind.NetworkError,
e.message ?? 'unexpected network error',
e.status,
);
identifyReject(e);
}

Expand Down

0 comments on commit df41f81

Please sign in to comment.