feat: improve error handling and logging in the web application

- Updated the error handling in `index.html` to include a retry button for failed app loads, enhancing user experience.
- Added session storage management to prevent repeated reloads on errors.
- Enhanced the `.gitignore` file to include log files, improving project cleanliness.
- Included error logging in `main.js` to ensure better tracking of issues during app initialization.
This commit is contained in:
2026-03-03 00:10:30 +03:00
parent 7ffa727832
commit 70b9050cb7
3 changed files with 27 additions and 5 deletions

3
.gitignore vendored
View File

@@ -14,3 +14,6 @@ htmlcov/
.pytest_cache/
*.cover
*.plan.md
# Logs
*.log

View File

@@ -73,14 +73,30 @@
var mainScript = document.getElementById("main-module");
if (mainScript) {
mainScript.addEventListener("error", function() {
var retryKey = "__dtLoadRetry";
try {
if (!sessionStorage.getItem(retryKey)) {
sessionStorage.setItem(retryKey, "1");
location.reload();
return;
}
sessionStorage.removeItem(retryKey);
} catch (_) {}
var loading = document.getElementById("loading");
if (loading && !loading.classList.contains("hidden")) {
loading.classList.add("hidden");
var err = document.getElementById("error");
if (err) {
err.hidden = false;
err.textContent = "Failed to load app. Check connection and try again.";
}
}
var err = document.getElementById("error");
if (err) {
err.hidden = false;
err.textContent = "";
err.appendChild(document.createTextNode("Failed to load app. Check connection and try again. "));
var retryBtn = document.createElement("button");
retryBtn.type = "button";
retryBtn.className = "error-retry";
retryBtn.textContent = "Retry";
retryBtn.addEventListener("click", function() { location.reload(); });
err.appendChild(retryBtn);
}
});
}

View File

@@ -68,6 +68,9 @@ applyLangToUi();
logger.info("App init", "lang=" + state.lang);
try {
sessionStorage.removeItem("__dtLoadRetry");
} catch (_) {}
window.__dtReady = true;
/**