mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-07 20:17:05 +03:00
Merge pull request #1222 from mchangrh/custom5xx
custom error handler for 5xx
This commit is contained in:
@@ -28,20 +28,18 @@ async function wait<T>(condition: () => T | false, timeout = 5000, check = 100):
|
|||||||
* @returns {string} errorMessage
|
* @returns {string} errorMessage
|
||||||
*/
|
*/
|
||||||
function getErrorMessage(statusCode: number, responseText: string): string {
|
function getErrorMessage(statusCode: number, responseText: string): string {
|
||||||
let errorMessage = "";
|
|
||||||
const postFix = (responseText ? "\n\n" + responseText : "");
|
const postFix = (responseText ? "\n\n" + responseText : "");
|
||||||
|
// display response body for 4xx
|
||||||
if([400, 429, 409, 502, 503, 0].includes(statusCode)) {
|
if([400, 429, 409, 0].includes(statusCode)) {
|
||||||
//treat them the same
|
return chrome.i18n.getMessage(statusCode + "") + " " + chrome.i18n.getMessage("errorCode") + statusCode + postFix;
|
||||||
|
} else if (statusCode >= 500 && statusCode <= 599) {
|
||||||
|
// 503 == 502
|
||||||
if (statusCode == 503) statusCode = 502;
|
if (statusCode == 503) statusCode = 502;
|
||||||
|
return chrome.i18n.getMessage(statusCode + "") + " " + chrome.i18n.getMessage("errorCode") + statusCode
|
||||||
errorMessage = chrome.i18n.getMessage(statusCode + "") + " " + chrome.i18n.getMessage("errorCode") + statusCode
|
+ "\n\n" + chrome.i18n.getMessage("statusReminder");
|
||||||
+ "\n\n" + chrome.i18n.getMessage("statusReminder");
|
|
||||||
} else {
|
} else {
|
||||||
errorMessage = chrome.i18n.getMessage("connectionError") + statusCode;
|
return chrome.i18n.getMessage("connectionError") + statusCode + postFix;
|
||||||
}
|
}
|
||||||
|
|
||||||
return errorMessage + postFix;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Gets percieved luminance of a color */
|
/* Gets percieved luminance of a color */
|
||||||
|
|||||||
Reference in New Issue
Block a user