feat: Better error handling on segment-url extraction

This commit is contained in:
nima.taheri@hootsuite.com 2022-08-10 12:28:00 -07:00
commit 8cfdb466d5

View file

@ -86,7 +86,12 @@ function processFile(type, baseUrl, initData, segments, filename, cb) {
fs.writeFileSync(downloadingFlag, ''); fs.writeFileSync(downloadingFlag, '');
} }
const segmentsUrl = segments.map(seg => baseUrl + seg.url); const segmentsUrl = segments.map(seg => {
if (!seg.url) {
throw new Error(`found a segment with an empty url: ${JSON.stringify(seg)}`);
}
return baseUrl + seg.url;
});
const initBuffer = Buffer.from(initData, "base64"); const initBuffer = Buffer.from(initData, "base64");
fs.writeFileSync(filePath, initBuffer); fs.writeFileSync(filePath, initBuffer);