Skip to content

Commit

Permalink
Add context to error logged when anchoring fails
Browse files Browse the repository at this point in the history
If the transcript fails to load in the video player app, it will reject the
`contentReady` promise that the client waits on. The client would then cause the
error to be thrown from `Guest.anchor`. Catch this error and add context to
indicate what has gone wrong.
  • Loading branch information
robertknight committed Jul 19, 2023
1 parent 682c542 commit 1bfb577
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/annotator/guest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,16 @@ export class Guest extends TinyEmitter implements Annotator, Destroyable {

this._sidebarRPC.on('deleteAnnotation', (tag: string) => this.detach(tag));

this._sidebarRPC.on('loadAnnotations', (annotations: AnnotationData[]) =>
annotations.forEach(annotation => this.anchor(annotation))
this._sidebarRPC.on(
'loadAnnotations',
async (annotations: AnnotationData[]) => {
try {
await Promise.all(annotations.map(ann => this.anchor(ann)));
} catch (e) {
/* istanbul ignore next */
console.warn('Failed to anchor annotations:', e);
}
}
);

this._sidebarRPC.on('showContentInfo', (info: ContentInfoConfig) =>
Expand Down

0 comments on commit 1bfb577

Please sign in to comment.