diff --git a/js/libtextsecure.js b/js/libtextsecure.js
index <HASH>..<HASH> 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 <HASH>..<HASH> 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));
                         }
                     }
                 }
Handle invalid responses better

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

// FREEBIE