window.errorWrittenToPage = false;
document.addEventListener("DOMContentLoaded", function() {
setTimeout(function() {
if(window.errorWrittenToPage != true)
{
setErrorDisp(500, "Internal Server Error", "Error while finding the error message - oh the irony");
}
}, 6000);
try
{
let errorInfo = JSON.parse(Cookies.get("errorInfo")); // eslint-disable-line no-undef
let statusCode = parseInt(errorInfo["API-Error-StatusCode"]);
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 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(parseInt(statusCode), errorReasonMsg, errorInfo["API-Error-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 = "")
{
window.errorWrittenToPage = true;
document.title = (" - Error " + code.toString());
document.getElementById("errCodeDisplay").innerHTML = (code.toString() + " - " + summary);
document.getElementById("errDetailDisplay").innerHTML = "Details: " + details;
if(subText)
document.getElementById("errSubText").innerHTML = subText;
}