From acae4afce37c3d5196c1bd36e0126c5a21463a32 Mon Sep 17 00:00:00 2001 From: lilia Date: Fri, 27 Nov 2015 16:17:37 -0800 Subject: [PATCH] Handle invalid responses better Depending on the response code, returning an HTTPError here will let us retry later, if appropriate. // FREEBIE --- js/libtextsecure.js | 3 ++- libtextsecure/api.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/js/libtextsecure.js b/js/libtextsecure.js index 736fffab4..6699788d5 100644 --- a/js/libtextsecure.js +++ b/js/libtextsecure.js @@ -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)); } } } diff --git a/libtextsecure/api.js b/libtextsecure/api.js index d33903410..dc6d401bb 100644 --- a/libtextsecure/api.js +++ b/libtextsecure/api.js @@ -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)); } } }