Wrap some long lines

This commit is contained in:
lilia 2014-11-06 18:13:54 -08:00
parent 0a3c03025b
commit 74bfc9d04e

View file

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