diff --git a/snot/snot.html b/snot/snot.html
index a59bfe2..d0857db 100644
--- a/snot/snot.html
+++ b/snot/snot.html
@@ -351,6 +351,7 @@
},
async search() {
+ this.errorMessage = "";
const response = await fetch("/search", {
method: "POST",
headers: { "Content-Type": "application/json" },
diff --git a/snot/snot.py b/snot/snot.py
index ca935f6..009e280 100755
--- a/snot/snot.py
+++ b/snot/snot.py
@@ -551,11 +551,14 @@ def fetch_videos(params: dict[str, str]) -> list[dict[str, Any]]:
rows: list[dict[str, Any]] = []
total: int | None = None
while total is None or len(rows) < total:
- response = client.get(
- "/videos",
- params={**params, "limit": "1000", "offset": str(len(rows))},
- headers={"Prefer": "count=exact"} if total is None else None,
- )
+ try:
+ response = client.get(
+ "/videos",
+ params={**params, "limit": "1000", "offset": str(len(rows))},
+ headers={"Prefer": "count=exact"} if total is None else None,
+ )
+ except httpx.ConnectError as e:
+ raise RuntimeError(f"Cannot reach database at {client.base_url} ({e}). Is the server running and reachable?") from e
response.raise_for_status()
page = response.json()
if total is None: