Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | 1x 1x 1x 1x 1x 1x 1x 1x 29x 5x 5x 1x 4x 4x 4x 4x 4x 1x 4x 4x 1x 2x 2x 1x 3x 3x 1x 1x 1x 1x 1x 1x 1x 2x 2x 1x 3x 3x 1x 20x 20x 20x 1x 40x 4x 4x 2x 3x 1x 1x 2x 3x 20x | import pathOr from 'ramda/src/pathOr';
import ConsumerErrorPayload from './ConsumerErrorPayload';
import ErrorType from '../../Constants/Error.type';
import HttpType from '../../Constants/Http.type';
import ConsumerErrorId from '../../Constants/ConsumerErrorId';
import ConsumerErrorCategory from '../../Constants/ConsumerErrorCategory';
import ConsumerErrorStatus from '../../Constants/ConsumerErrorStatus';
const API_ERROR_CODE_GENERIC = '10000';
const extractHttpStatus = error => pathOr(ConsumerErrorStatus.GENERIC, ['response', 'status'], error).toString();
const extractApiErrorCode = error => pathOr(API_ERROR_CODE_GENERIC, ['response', 'data', 'odata.error', 'code'], error);
const mapApiErrorCodeToConsumerErrorId = apiErrorCode => apiErrorCode.toString().substring(2);
const mapToApiServicePlayback = error => {
const httpStatus = extractHttpStatus(error.source);
const httpErrorCode = () => pathOr(null, [HttpType[httpStatus]], ConsumerErrorId);
const serviceErrorCode = () => mapApiErrorCodeToConsumerErrorId(extractApiErrorCode(error.source));
const errorCode = {
category: ConsumerErrorCategory.API_SERVICE_PLAYBACK,
id: httpErrorCode() || serviceErrorCode(),
status: httpStatus,
};
return new ConsumerErrorPayload(errorCode, error);
};
const mapToApiServicePlaybackMissingData = error => {
const errorCode = {
category: ConsumerErrorCategory.API_SERVICE_PLAYBACK,
id: ConsumerErrorId.API_SERVICE_PLAYBACK_MISSING_PLAYBACK_DETAILS,
status: ConsumerErrorStatus.GENERIC,
};
return new ConsumerErrorPayload(errorCode, error);
};
const mapToApiServiceConcurrentUserLimit = error => {
const errorCode = {
category: ConsumerErrorCategory.API_SERVICE_PLAYBACK,
id: ConsumerErrorId.API_SERVICE_PLAYBACK_CONCURRENT_USER_LIMIT,
status: extractHttpStatus(error.source),
};
return new ConsumerErrorPayload(errorCode, error);
};
const mapToApiServiceRestrictedLocation = error => {
const errorCode = {
category: ConsumerErrorCategory.API_SERVICE_PLAYBACK,
id: mapApiErrorCodeToConsumerErrorId(extractApiErrorCode(error.source)),
status: extractHttpStatus(error.source),
};
return new ConsumerErrorPayload(errorCode, error);
};
const mapToPlaybackSourceStartup = error => {
const errorCode = {
category: ConsumerErrorCategory.PLAYBACK_SOURCE,
id: ConsumerErrorId.PLAYBACK_SOURCE_STARTUP,
status: ConsumerErrorStatus.PLAYBACK_SOURCE_STARTUP,
};
return new ConsumerErrorPayload(errorCode, error);
};
const mapToPlaybackSourceMidStream = error => {
const errorCode = {
category: ConsumerErrorCategory.PLAYBACK_SOURCE,
id: ConsumerErrorId.PLAYBACK_SOURCE_MIDSTREAM,
status: ConsumerErrorStatus.PLAYBACK_SOURCE_MIDSTREAM,
};
return new ConsumerErrorPayload(errorCode, error);
};
const mapToPlaybackSourceDrm = error => {
const errorCode = {
category: ConsumerErrorCategory.PLAYBACK_SOURCE,
id: ConsumerErrorId.DRM,
status: ConsumerErrorStatus.DRM,
};
return new ConsumerErrorPayload(errorCode, error);
};
const mapToPlaybackConnectionLost = error => {
const errorCode = {
category: ConsumerErrorCategory.PLAYBACK_INTERRUPTED_CONNECTION_LOST,
id: ConsumerErrorId.PLAYBACK_INTERRUPTED_CONNECTION_LOST,
status: ConsumerErrorStatus.PLAYBACK_INTERRUPTED_CONNECTION_LOST,
};
return new ConsumerErrorPayload(errorCode, error);
};
const mapToUnkownError = error => {
const httpStatus = extractHttpStatus(error.source);
const errorCode = {
category: ConsumerErrorCategory.UNKNOWN,
id: pathOr(ConsumerErrorStatus.GENERIC, [HttpType[httpStatus]], ConsumerErrorId),
status: httpStatus,
};
return new ConsumerErrorPayload(errorCode, error);
};
const mapToConsumerError = error => {
switch (error.type) {
case ErrorType.API_SERVICE_PLAYBACK:
return mapToApiServicePlayback(error);
case ErrorType.API_SERVICE_PLAYBACK_MISSING_DATA:
case ErrorType.API_SERVICE_PLAYBACK_MEDIA_UNAVAILABLE:
case ErrorType.API_SERVICE_PLAYBACK_ASSET_UNAVAILABLE:
case ErrorType.API_SERVICE_PLAYBACK_PLAYBACKDETAILS_UNAVAILABLE:
return mapToApiServicePlaybackMissingData(error);
case ErrorType.API_SERVICE_PLAYBACK_CONCURRENT_USER_LIMIT:
return mapToApiServiceConcurrentUserLimit(error);
case ErrorType.API_SERVICE_PLAYBACK_RESTRICTED_LOCATION:
return mapToApiServiceRestrictedLocation(error);
case ErrorType.PLAYBACK_SOURCE_STARTUP:
return mapToPlaybackSourceStartup(error);
case ErrorType.PLAYBACK_SOURCE_MIDSTREAM:
return mapToPlaybackSourceMidStream(error);
case ErrorType.LICENSE_REQUEST_FAILED:
case ErrorType.CERTIFICATE_REQUEST_FAILED:
return mapToPlaybackSourceDrm(error);
case ErrorType.PLAYBACK_INTERRUPTED_CONNECTION_LOST:
return mapToPlaybackConnectionLost(error);
default:
return mapToUnkownError(error);
}
};
export default mapToConsumerError;
|