let errorWrittenToPage = false;
document.addEventListener("DOMContentLoaded", function() {
setTimeout(function() {
if(errorWrittenToPage != true)
setErrorDisp(500, "Internal Server Error", "Error while finding the error message - oh the irony");
}, 5000);
try
{
let errorInfo = JSON.parse(atob(Cookies.get("errorInfo"))); // eslint-disable-line no-undef
let statusCode = Number(errorInfo ? errorInfo.code : NaN);
if(isNaN(statusCode))
statusCode = 500;
let errorReasonMsg = "";
let errorSubtext = "";
switch(statusCode)
{
case 404:
errorReasonMsg = "Not Found";
errorSubtext = " couldn't find a resource that corresponds to the URL you have entered.
Please make sure the URL is correct or \">visit the documentation by clicking here.";
break;
case 429:
errorReasonMsg = "Too Many Requests";
errorSubtext = "You have sent too many requests to the server in a short amount of time.
Please wait a few minutes and try again.";
break;
case 500: default:
errorReasonMsg = "Internal Server Error";
errorSubtext = " encountered an unexpected internal error.
If this error persists and error details were provided on this page, please \">contact me with the error details and I will try to fix it and/or help you.
Alternatively, \">visit the documentation by clicking here.";
break;
}
setErrorDisp(statusCode, errorReasonMsg, errorInfo.message, errorSubtext);
}
catch(err)
{
setErrorDisp(500, "Internal Server Error", "Error while finding the error message - oh the irony");
}
});
/**
* Sets the error display of the page
* @param {Number} code
* @param {String} summary
* @param {String} details
* @param {String} subText
*/
function setErrorDisp(code = 500, summary = "Internal Server Error", details = "No details provided", subText = "")
{
errorWrittenToPage = true;
document.title = (" - Error " + code.toString());
document.getElementById("errCodeDisplay").innerText = (code.toString() + " - " + summary);
document.getElementById("errDetailDisplay").innerText = "Details: " + details;
if(subText)
document.getElementById("errSubText").innerText = subText;
}