mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-09 04:57:09 +03:00
Moved error message handling to a util file and added a link to the status site.
This commit is contained in:
32
popup.js
32
popup.js
@@ -895,18 +895,7 @@ function runThePopup() {
|
||||
|
||||
clearTimes();
|
||||
} else {
|
||||
let errorMessage = "";
|
||||
|
||||
if([400, 429, 409, 502, 0].includes(response.statusCode)) {
|
||||
//treat them the same
|
||||
if (response.statusCode == 503) response.statusCode = 502;
|
||||
|
||||
errorMessage = chrome.i18n.getMessage(response.statusCode + "") + " " + chrome.i18n.getMessage("errorCode") + response.statusCode;
|
||||
} else {
|
||||
errorMessage = chrome.i18n.getMessage("connectionError") + response.statusCode;
|
||||
}
|
||||
|
||||
document.getElementById("submitTimesInfoMessage").innerText = errorMessage;
|
||||
document.getElementById("submitTimesInfoMessage").innerText = getErrorMessage(response.statusCode);
|
||||
document.getElementById("submitTimesInfoMessageContainer").style.display = "unset";
|
||||
|
||||
SB.submitTimesInfoMessageContainer.style.display = "unset";
|
||||
@@ -1138,7 +1127,7 @@ function runThePopup() {
|
||||
SB.usernameInput.style.display = "none";
|
||||
|
||||
SB.setUsernameStatusContainer.style.display = "unset";
|
||||
SB.setUsernameStatus.innerText = "Couldn't connect to server. Error code: " + xmlhttp.status;
|
||||
SB.setUsernameStatus.innerText = getErrorMessage(xmlhttp.status);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1160,15 +1149,7 @@ function runThePopup() {
|
||||
|
||||
SB.setUsernameStatus.innerText = chrome.i18n.getMessage("success");
|
||||
} else if (xmlhttp.readyState == 4) {
|
||||
let errorMessage = "";
|
||||
|
||||
if([400, 429, 409, 502].includes(xmlhttp.status)) {
|
||||
errorMessage = chrome.i18n.getMessage(xmlhttp.status);
|
||||
} else {
|
||||
errorMessage = chrome.i18n.getMessage("connectionError") + xmlhttp.status;
|
||||
}
|
||||
|
||||
SB.setUsernameStatus.innerText = errorMessage;
|
||||
SB.setUsernameStatus.innerText = getErrorMessageI(xmlhttp.status);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1224,12 +1205,7 @@ function runThePopup() {
|
||||
//failure: duplicate vote
|
||||
addVoteMessage(chrome.i18n.getMessage("voteFail"), UUID)
|
||||
} else if (response.successType == -1) {
|
||||
if (response.statusCode == 502) {
|
||||
addVoteMessage(chrome.i18n.getMessage("serverDown"), UUID)
|
||||
} else {
|
||||
//failure: unknown error
|
||||
addVoteMessage(chrome.i18n.getMessage("connectionError") + response.statusCode, UUID)
|
||||
}
|
||||
addVoteMessage(getErrorMessage(response.statusCode), UUID)
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user