Properly handle server error

This commit is contained in:
Ajay Ramachandran 2020-04-09 14:08:26 -04:00
parent ae690f0c65
commit a50f030a3b

View file

@ -605,12 +605,13 @@ function sponsorsLookup(id: string, channelIDPromise?) {
categories
}).then(async (response: Response) => {
if (response.status === 200) {
sponsorDataFound = true;
let recievedSegments: SponsorTime[] = await response.json();
if (!recievedSegments.length) {
console.error("[SponsorBlock] Server returned malformed response: " + JSON.stringify(recievedSegments));
return;
}
sponsorDataFound = true;
// Check if any old submissions should be kept
if (sponsorTimes !== null) {