Handle invalid responses better

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

// FREEBIE
This commit is contained in:
lilia 2015-11-27 16:17:37 -08:00
parent 7bf94c33d5
commit acae4afce3
2 changed files with 4 additions and 2 deletions

View file

@ -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));
}
}
}

View file

@ -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));
}
}
}