Skip to content

Commit

Permalink
fix(SUP-43014): [elearning] specified error message for v7 for IP res…
Browse files Browse the repository at this point in the history
…triction (#846)

Description of the Changes
add specific error message to IP restriction block.

part of - kaltura/playkit-js#791, kaltura/playkit-js-ui#936

Resolves SUP-43014
  • Loading branch information
Tzipi-kaltura authored Sep 11, 2024
1 parent 342efff commit bba1e0b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/common/utils/error-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ const isBlockAction = (error: Error): boolean => error.code === 2001;
const isMediaNotReady = (error: Error): boolean => error.code === 2002;
const isGeolocationRestricted = (error: Error): boolean => error.data?.messages && error.data?.messages[0].code === 'COUNTRY_RESTRICTED';
const isSessionRestricted = (error: Error): boolean => error.data?.messages && error.data?.messages[0].code === 'SESSION_RESTRICTED';
const isIPRestricted = (error: Error): boolean => error.data?.messages && error.data?.messages[0].code === 'IP_RESTRICTED';

const isSessionRestrictedError = (error: Error): boolean => isBackEndError(error) && isBlockAction(error) && isSessionRestricted(error);
const isGeolocationError = (error: Error): boolean => isBackEndError(error) && isBlockAction(error) && isGeolocationRestricted(error);
const isMediaNotReadyError = (error: Error): boolean => isBackEndError(error) && isMediaNotReady(error);
const isIPRestrictedError = (error: Error): boolean => isBackEndError(error) && isBlockAction(error) && isIPRestricted(error);

const conditionsToErrors: any[] = [
[isSessionRestrictedError, Error.Category.MEDIA_UNAVAILABLE],
[isGeolocationError, Error.Category.GEO_LOCATION],
[isMediaNotReadyError, Error.Category.MEDIA_NOT_READY]
[isMediaNotReadyError, Error.Category.MEDIA_NOT_READY],
[isIPRestrictedError, Error.Category.IP_RESTRICTED]
];

function getErrorCategory(error: Error): number {
Expand Down

0 comments on commit bba1e0b

Please sign in to comment.