Added better error messages to voting.

This commit is contained in:
Ajay Ramachandran
2019-07-29 21:06:15 -04:00
parent 366fd43752
commit 0d0b919106
3 changed files with 17 additions and 6 deletions

View File

@@ -100,12 +100,14 @@ function submitVote(type, UUID, callback) {
} else if (xmlhttp.readyState == 4 && xmlhttp.status == 405) { } else if (xmlhttp.readyState == 4 && xmlhttp.status == 405) {
//duplicate vote //duplicate vote
callback({ callback({
successType: 0 successType: 0,
statusCode: xmlhttp.status
}); });
} else if (error) { } else if (error) {
//error while connect //error while connect
callback({ callback({
successType: -1 successType: -1,
statusCode: xmlhttp.status
}); });
} }
}) })

View File

@@ -710,8 +710,13 @@ function vote(type, UUID) {
//failure: duplicate vote //failure: duplicate vote
addLoadingInfo("It seems you've already voted before", UUID) addLoadingInfo("It seems you've already voted before", UUID)
} else if (response.successType == -1) { } else if (response.successType == -1) {
//failure: duplicate vote if (response.statusCode == 502) {
addLoadingInfo("A connection error has occured.", UUID) addLoadingInfo("It seems the sever is down. Contact the dev immediately.", UUID)
} else {
//failure: unknown error
addLoadingInfo("A connection error has occured. Error code: " + response.statusCode, UUID)
}
} }
} }
}); });

View File

@@ -750,8 +750,12 @@ function vote(type, UUID) {
//failure: duplicate vote //failure: duplicate vote
addVoteMessage("You have already voted this way before.", UUID) addVoteMessage("You have already voted this way before.", UUID)
} else if (response.successType == -1) { } else if (response.successType == -1) {
//failure: duplicate vote if (response.statusCode == 502) {
addVoteMessage("A connection error has occured.", UUID) addVoteMessage("It seems the sever is down. Contact the dev immediately.", UUID)
} else {
//failure: unknown error
addVoteMessage("A connection error has occured. Error code: " + response.statusCode, UUID)
}
} }
} }
}); });