Merge branch 'master' into chapters

This commit is contained in:
Ajay Ramachandran
2022-03-12 16:56:53 -05:00
committed by GitHub
21 changed files with 1388 additions and 537 deletions

View File

@@ -72,20 +72,18 @@ function getFormattedTime(seconds: number, precise?: boolean): string {
* @returns {string} errorMessage
*/
function getErrorMessage(statusCode: number, responseText: string): string {
let errorMessage = "";
const postFix = (responseText ? "\n\n" + responseText : "");
if([400, 429, 409, 502, 503, 0].includes(statusCode)) {
//treat them the same
const postFix = ((responseText && !responseText.includes(`cf-wrapper`)) ? "\n\n" + responseText : "");
// display response body for 4xx
if([400, 429, 409, 0].includes(statusCode)) {
return chrome.i18n.getMessage(statusCode + "") + " " + chrome.i18n.getMessage("errorCode") + statusCode + postFix;
} else if (statusCode >= 500 && statusCode <= 599) {
// 503 == 502
if (statusCode == 503) statusCode = 502;
errorMessage = chrome.i18n.getMessage(statusCode + "") + " " + chrome.i18n.getMessage("errorCode") + statusCode
+ "\n\n" + chrome.i18n.getMessage("statusReminder");
return chrome.i18n.getMessage(statusCode + "") + " " + chrome.i18n.getMessage("errorCode") + statusCode
+ "\n\n" + chrome.i18n.getMessage("statusReminder");
} else {
errorMessage = chrome.i18n.getMessage("connectionError") + statusCode;
return chrome.i18n.getMessage("connectionError") + statusCode + postFix;
}
return errorMessage + postFix;
}
/* Gets percieved luminance of a color */