From 3b812168920cab236a75ba02edcb0997967eb702 Mon Sep 17 00:00:00 2001 From: Abdussamet Kocak Date: Sat, 17 Oct 2026 15:35:45 +0300 Subject: [PATCH] fix(snot): surface DB connection errors and clear stale error banner on search --- snot/snot.html | 1 + snot/snot.py | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) 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: