debug: показывать ошибку в карточке клиента вместо пустого экрана

- Обернуть renderClientHistory в try/catch — показывает текст ошибки
- Добавить .catch() в mount() для перехвата unhandled promise rejection
- Версия clients.js: 20260518c
This commit is contained in:
wasrusgen 2026-05-18 00:21:28 +03:00
parent 860c768572
commit 057842b7e6
2 changed files with 18 additions and 3 deletions

View File

@ -29,7 +29,13 @@ const Clients = (function () {
renderClientProposalsPage(clientKey);
} else if (sub.startsWith("client/")) {
const clientKey = decodeURIComponent(sub.slice(7));
renderClientHistory(clientKey);
renderClientHistory(clientKey).catch(e => {
if (root) root.appendChild(el(
`<div class="error" style="padding:16px;margin:16px;border-radius:10px;background:#fff3f3;">
<b>Ошибка карточки:</b> ${escHtml(e.message)}
</div>`
));
});
} else {
renderList();
}
@ -565,7 +571,7 @@ const Clients = (function () {
async function renderClientHistory(clientKey) {
root.innerHTML = "";
root.appendChild(headerEl("Карточка клиента", "#/clients"));
try {
// Берём из кеша если есть
let clients = clientsCache?.clients;
if (!clients) {
@ -753,6 +759,15 @@ const Clients = (function () {
proposalPlaceholder.replaceWith(propWrapper);
// (управление перенесено наверх — сразу под шапку)
} catch (e) {
root.appendChild(el(
`<div class="error" style="padding:16px;margin:12px 16px;border-radius:10px;background:#fff3f3;">
<b>Ошибка загрузки карточки:</b><br>${escHtml(e.message)}<br>
<small style="color:#999">${escHtml(e.stack ? e.stack.split('\n')[1] || '' : '')}</small>
</div>`
));
throw e;
}
}
/* ===================== Управление карточкой (edit / delete) ===================== */

View File

@ -39,7 +39,7 @@
<script src="assets/podbor.config.js?v=20260516h"></script>
<script src="assets/podbor.picts.js?v=20260516h"></script>
<script src="assets/podbor.js?v=20260517d"></script>
<script src="assets/clients.js?v=20260518b"></script>
<script src="assets/clients.js?v=20260518c"></script>
<script src="assets/zamer-picts.js?v=20260516h"></script>
<script src="assets/measurements.js?v=20260517d"></script>
<script src="assets/request.js?v=20260517d"></script>