Handle invalid responses better

Depending on the response code, returning an HTTPError here will let us
retry later, if appropriate.

// FREEBIE
pull/749/head
lilia 10 years ago
parent 7bf94c33d5
commit acae4afce3

@ -36232,7 +36232,8 @@ var TextSecureServer = (function() {
try { result = JSON.parse(xhr.responseText + ''); } catch(e) {}
if (options.validateResponse) {
if (!validateResponse(result, options.validateResponse)) {
reject(new Error('Invalid response'));
console.log(options.type, url, xhr.status, 'Error');
reject(HTTPError(xhr.status, result, options.stack));
}
}
}

@ -51,7 +51,8 @@ var TextSecureServer = (function() {
try { result = JSON.parse(xhr.responseText + ''); } catch(e) {}
if (options.validateResponse) {
if (!validateResponse(result, options.validateResponse)) {
reject(new Error('Invalid response'));
console.log(options.type, url, xhr.status, 'Error');
reject(HTTPError(xhr.status, result, options.stack));
}
}
}

Loading…
Cancel
Save