better error message on login with wrong server address, fixes #15

This commit is contained in:
Jeena 2014-05-22 21:29:39 +02:00
parent 54c87e58d8
commit 89142c54c0
4 changed files with 16 additions and 4 deletions

View file

@ -241,7 +241,11 @@ OwnCloud.login = function(server_url, user, password, callback) {
if(xhr.status == 200) { if(xhr.status == 200) {
callback(JSON.parse(xhr.responseText)) callback(JSON.parse(xhr.responseText))
} else { } else {
alert("error: " + xhr.status + " " + xhr.statusText) if(xhr.status == 0) {
alert("Something went wrong, please check your credentials and the server address")
} else {
alert("error: " + xhr.status + " " + xhr.statusText);
}
} }
} }
} }

View file

@ -215,7 +215,11 @@ Pond.login = function(server_url, user, password, callback) {
if(xhr.status == 201) { if(xhr.status == 201) {
callback(JSON.parse(xhr.responseText)) callback(JSON.parse(xhr.responseText))
} else { } else {
alert("error: " + typeof(xhr.status) + " " + xhr.statusText + "\n\n" + xhr.responseText) if(xhr.status == 0) {
alert("Something went wrong, please check your credentials and the server address")
} else {
alert("error: " + typeof(xhr.status) + " " + xhr.statusText + "\n\n" + xhr.responseText);
}
} }
} }
} }

View file

@ -174,11 +174,15 @@ TinyTinyRSS.login = function(server_url, user, password, callback) {
if(xhr.readyState == 4) { if(xhr.readyState == 4) {
if(xhr.status == 200) { if(xhr.status == 200) {
callback(JSON.parse(xhr.responseText).content) callback(JSON.parse(xhr.responseText).content)
} else {
if(xhr.status == 0) {
alert("Something went wrong, please check your credentials and the server address")
} else { } else {
alert("error: " + xhr.status + " " + xhr.statusText) alert("error: " + xhr.status + " " + xhr.statusText)
} }
} }
} }
}
xhr.open("POST", url, true); xhr.open("POST", url, true);
xhr.send(JSON.stringify(options)); xhr.send(JSON.stringify(options));
} }