Hide error under details

This commit is contained in:
Pavel Djundik 2017-12-05 15:17:31 +02:00
parent e3823803aa
commit 2afd4d7ec4

View File

@ -27,10 +27,21 @@ window.g_LoungeErrorHandler = function LoungeErrorHandler(error) {
title = document.getElementById("loading-page-message"); title = document.getElementById("loading-page-message");
title.textContent = "An error has occured that prevented the client from loading correctly."; title.textContent = "An error has occured that prevented the client from loading correctly.";
var element = document.createElement("p"); var summary = document.createElement("summary");
element.contentEditable = true; summary.textContent = "More details";
element.textContent = error instanceof ErrorEvent ? error.message : error;
title.parentNode.insertBefore(element, title.nextSibling); if (error instanceof ErrorEvent) {
error = error.message + "\n\n" + error.stack + "\n\nView developer tools console for more information and a better stacktrace.";
}
var data = document.createElement("pre");
data.contentEditable = true;
data.textContent = error;
var details = document.createElement("details");
details.appendChild(summary);
details.appendChild(data);
title.parentNode.insertBefore(details, title.nextSibling);
}; };
window.addEventListener("error", window.g_LoungeErrorHandler); window.addEventListener("error", window.g_LoungeErrorHandler);