Improve error handling to actually render in the UI.

pull/11769/head
Andriy Dzikh 2021-06-25 11:13:46 -07:00
parent f57d7ae723
commit e9932aa7db
1 changed files with 11 additions and 1 deletions

View File

@ -1,7 +1,17 @@
// Displays an error message to the UI. Any previous message will be erased.
function displayError(message) {
console.error(message);
// Clear the body of all children.
while (document.body.firstChild) {
document.body.removeChild(document.body.firstChild);
}
const element = document.createElement("p");
element.innerText = "Error: " + message;
element.style.color = "red";
element.style.fontFamily = "Arial";
element.style.fontWeight = "bold";
element.style.margin = "5rem";
document.body.appendChild(element);
}
// Creates a generator that reads the response body one line at a time.