Wrap some long lines
This commit is contained in:
parent
0a3c03025b
commit
74bfc9d04e
1 changed files with 40 additions and 33 deletions
73
js/api.js
73
js/api.js
|
@ -81,39 +81,46 @@ window.textsecure.api = function() {
|
||||||
},
|
},
|
||||||
|
|
||||||
error : function(jqXHR, textStatus, errorThrown) {
|
error : function(jqXHR, textStatus, errorThrown) {
|
||||||
var code = jqXHR.status;
|
var code = jqXHR.status;
|
||||||
if (code == 200) {
|
if (code == 200) {
|
||||||
// happens sometimes when we get no response
|
// happens sometimes when we get no response
|
||||||
// (TODO: Fix server to return 204? instead)
|
// (TODO: Fix server to return 204? instead)
|
||||||
resolve(null);
|
resolve(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (code > 999 || code < 100)
|
if (code > 999 || code < 100)
|
||||||
code = -1;
|
code = -1;
|
||||||
try {
|
try {
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case -1:
|
case -1:
|
||||||
textsecure.throwHumanError(code, "HTTPError", "Failed to connect to the server, please check your network connection.");
|
textsecure.throwHumanError(code, "HTTPError",
|
||||||
case 413:
|
"Failed to connect to the server, please check your network connection.");
|
||||||
textsecure.throwHumanError(code, "HTTPError", "Rate limit exceeded, please try again later.");
|
case 413:
|
||||||
case 403:
|
textsecure.throwHumanError(code, "HTTPError",
|
||||||
textsecure.throwHumanError(code, "HTTPError", "Invalid code, please try again.");
|
"Rate limit exceeded, please try again later.");
|
||||||
case 417:
|
case 403:
|
||||||
// TODO: This shouldn't be a thing?, but its in the API doc?
|
textsecure.throwHumanError(code, "HTTPError",
|
||||||
textsecure.throwHumanError(code, "HTTPError", "Number already registered.");
|
"Invalid code, please try again.");
|
||||||
case 401:
|
case 417:
|
||||||
textsecure.throwHumanError(code, "HTTPError", "Invalid authentication, most likely someone re-registered and invalidated our registration.");
|
// TODO: This shouldn't be a thing?, but its in the API doc?
|
||||||
case 404:
|
textsecure.throwHumanError(code, "HTTPError",
|
||||||
textsecure.throwHumanError(code, "HTTPError", "Number is not registered with TextSecure.");
|
"Number already registered.");
|
||||||
default:
|
case 401:
|
||||||
textsecure.throwHumanError(code, "HTTPError", "The server rejected our query, please file a bug report.");
|
textsecure.throwHumanError(code, "HTTPError",
|
||||||
}
|
"Invalid authentication, most likely someone re-registered and invalidated our registration.");
|
||||||
} catch (e) {
|
case 404:
|
||||||
if (jqXHR.responseJSON)
|
textsecure.throwHumanError(code, "HTTPError",
|
||||||
e.response = jqXHR.responseJSON;
|
"Number is not registered with TextSecure.");
|
||||||
reject(e);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue