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 | 1x 1x 1x 18x 12x 11x 11x 1x 4x 4x 3x 3x 3x 3x 1x 4x 1x | import {
never,
of,
} from 'rxjs';
import isEmpty from '../../../Shared/Utils/isEmpty';
import ErrorType from '../../../Errors/Constants/Error.type';
const interceptPlaybackServiceResponse = handleError => serviceResponse => {
if (isEmpty(serviceResponse) || typeof serviceResponse !== 'object') {
handleError({
type: ErrorType.API_SERVICE_PLAYBACK_MISSING_DATA,
source: new Error(ErrorType.API_SERVICE_PLAYBACK_MISSING_DATA),
});
return never();
}
const response = Object
.keys(serviceResponse)
.reduce((output, currentService) => {
const service = serviceResponse[currentService];
if (isEmpty(service)) {
const type = `API_SERVICE_PLAYBACK_${currentService.toUpperCase()}_UNAVAILABLE`;
const source = new Error(type);
handleError({
type,
source,
});
output[currentService] = null;
} else {
output[currentService] = service;
}
return output;
}, {});
return of(response);
};
export default interceptPlaybackServiceResponse;
|