diff --git a/static/js/app.js b/static/js/app.js index 5d37711..43464dd 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -2148,7 +2148,15 @@ async function loadBookList() { try { const res = await fetch('/books/'); + if (!res.ok) { + listEl.innerHTML = `

Server error ${res.status} loading books.

`; + return; + } const books = await res.json(); + if (!Array.isArray(books)) { + listEl.innerHTML = `

Unexpected response from server.

`; + return; + } if (!books.length) { listEl.innerHTML = '

No books yet. Drop an .epub or .pdf above.

'; return; @@ -2169,7 +2177,7 @@ async function loadBookList() { } renderBookList(decrypted); } catch (e) { - if (listEl) listEl.innerHTML = '

Failed to load books.

'; + if (listEl) listEl.innerHTML = `

Error: ${e.message}

`; } }