From 74bfc9d04ee28b3b5c848e55fb30286248d3f057 Mon Sep 17 00:00:00 2001 From: lilia Date: Thu, 6 Nov 2014 18:13:54 -0800 Subject: [PATCH] Wrap some long lines --- js/api.js | 73 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 33 deletions(-) diff --git a/js/api.js b/js/api.js index 2ad5aa8a8..d7c45f82a 100644 --- a/js/api.js +++ b/js/api.js @@ -81,39 +81,46 @@ window.textsecure.api = function() { }, error : function(jqXHR, textStatus, errorThrown) { - var code = jqXHR.status; - if (code == 200) { - // happens sometimes when we get no response - // (TODO: Fix server to return 204? instead) - resolve(null); - return; - } - if (code > 999 || code < 100) - code = -1; - try { - switch (code) { - case -1: - textsecure.throwHumanError(code, "HTTPError", "Failed to connect to the server, please check your network connection."); - case 413: - textsecure.throwHumanError(code, "HTTPError", "Rate limit exceeded, please try again later."); - case 403: - textsecure.throwHumanError(code, "HTTPError", "Invalid code, please try again."); - case 417: - // TODO: This shouldn't be a thing?, but its in the API doc? - textsecure.throwHumanError(code, "HTTPError", "Number already registered."); - case 401: - textsecure.throwHumanError(code, "HTTPError", "Invalid authentication, most likely someone re-registered and invalidated our registration."); - case 404: - textsecure.throwHumanError(code, "HTTPError", "Number is not registered with TextSecure."); - default: - textsecure.throwHumanError(code, "HTTPError", "The server rejected our query, please file a bug report."); - } - } catch (e) { - if (jqXHR.responseJSON) - e.response = jqXHR.responseJSON; - reject(e); - } - } + var code = jqXHR.status; + if (code == 200) { + // happens sometimes when we get no response + // (TODO: Fix server to return 204? instead) + resolve(null); + return; + } + if (code > 999 || code < 100) + code = -1; + try { + switch (code) { + case -1: + textsecure.throwHumanError(code, "HTTPError", + "Failed to connect to the server, please check your network connection."); + case 413: + textsecure.throwHumanError(code, "HTTPError", + "Rate limit exceeded, please try again later."); + case 403: + textsecure.throwHumanError(code, "HTTPError", + "Invalid code, please try again."); + case 417: + // TODO: This shouldn't be a thing?, but its in the API doc? + textsecure.throwHumanError(code, "HTTPError", + "Number already registered."); + case 401: + textsecure.throwHumanError(code, "HTTPError", + "Invalid authentication, most likely someone re-registered and invalidated our registration."); + case 404: + textsecure.throwHumanError(code, "HTTPError", + "Number is not registered with TextSecure."); + default: + textsecure.throwHumanError(code, "HTTPError", + "The server rejected our query, please file a bug report."); + } + } catch (e) { + if (jqXHR.responseJSON) + e.response = jqXHR.responseJSON; + reject(e); + } + } }); }); };