Skip to content

Commit

Permalink
feat(FEC-13652): add meaningful error message
Browse files Browse the repository at this point in the history
  • Loading branch information
lianbenjamin committed Apr 4, 2024
1 parent 23918fa commit 89ebfd7
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/kaltura-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,31 @@ export class KalturaPlayer extends FakeEventTarget {
this.setMedia(mediaConfig);
return mediaConfig;
} catch (e) {
const error = new Error(Error.Severity.CRITICAL, Error.Category.PLAYER, Error.Code.LOAD_FAILED, e);
const category = this._getErrorCategory(e);
const error = new Error(Error.Severity.CRITICAL, category, Error.Code.LOAD_FAILED, e);
this._localPlayer.dispatchEvent(new FakeEvent(CoreEventType.ERROR, error));
throw e;
}
}

private _getErrorCategory(error: Error): number {
if (error.category === 2) { // category is Service from provider - BE issue

Check failure on line 181 in src/kaltura-player.ts

View workflow job for this annotation

GitHub Actions / lint / running-tests (ubuntu-latest)

Insert `⏎·····`
if (error.code === 2001) { // block action

Check failure on line 182 in src/kaltura-player.ts

View workflow job for this annotation

GitHub Actions / lint / running-tests (ubuntu-latest)

Insert `⏎·······`
const code = error.data?.messages ? error.data?.messages[0].code : '';
if (code === 'SESSION_RESTRICTED') {
return Error.Category.MEDIA_UNAVAILABLE;
}
if (code === 'COUNTRY_RESTRICTED') {
return Error.Category.GEO_LOCATION;
}
}
if (error.code === 2002) { // media is not ready

Check failure on line 191 in src/kaltura-player.ts

View workflow job for this annotation

GitHub Actions / lint / running-tests (ubuntu-latest)

Insert `⏎·······`
return Error.Category.MEDIA_NOT_READY;
}
}
return Error.Category.PLAYER;
}

public setMedia(mediaConfig: KPMediaConfig): void {
KalturaPlayer._logger.debug('setMedia', mediaConfig);
this.reset(true);
Expand Down

0 comments on commit 89ebfd7

Please sign in to comment.