fix: surface streamed load failures inline
All checks were successful
deploy / test-backend (push) Successful in 30m44s
deploy / test-frontend (push) Successful in 10m46s
deploy / build-and-push (push) Successful in 10m59s
deploy / deploy (push) Successful in 13s

The streamed loaders on bookmarks, collections, library, search, and the
collection detail page swallowed only ApiError into their in-band `error`
field and re-threw anything else. A raw network failure (a non-ApiError
TypeError from fetch) therefore escaped the `{#await}` to SvelteKit's
generic error page. On the collection detail page a content-load failure
showed a misleading "this collection is empty", and on search a failed
results query showed a false "no matches" because the streamed `error`
was never rendered.

Fold non-ApiError failures into the same in-band `error` so every
transient blip renders as an inline message, add a `contentError` branch
to the collection detail grid, and render the search results `error` in
both result views.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
MechaCat02
2026-07-07 19:11:37 +02:00
parent fee68dd9ac
commit 51ea254dde
10 changed files with 145 additions and 28 deletions

View File

@@ -180,7 +180,11 @@
{#await data.results}
<SearchResultsSkeleton />
{:then r}
{#if r.results.length === 0}
{#if r.error}
<p class="error" role="alert" data-testid="search-results-error">
Couldn't load results: {r.error}
</p>
{:else if r.results.length === 0}
<p class="hint" data-testid="search-content-empty">
No pages match this search.
</p>
@@ -288,7 +292,11 @@
{#await data.results}
<SearchResultsSkeleton />
{:then r}
{#if data.view === 'pages'}
{#if r.error}
<p class="error" role="alert" data-testid="search-results-error">
Couldn't load results: {r.error}
</p>
{:else if data.view === 'pages'}
{#if r.pages.length === 0}
<p class="hint" data-testid="search-pages-empty">
No pages tagged with "{data.tag}".

View File

@@ -92,10 +92,11 @@ export const load: PageLoad = async ({ url }) => {
if (e instanceof ApiError && e.status === 401) {
return { ...base, authenticated: false, results: Promise.resolve(emptyResults) };
}
if (e instanceof ApiError) {
return { ...base, error: e.message, results: Promise.resolve(emptyResults) };
}
throw e;
// Any other HTTP error or a raw network failure (a non-ApiError
// TypeError) is surfaced inline rather than escaping to the framework
// error page.
const message = e instanceof ApiError ? e.message : 'Something went wrong.';
return { ...base, error: message, results: Promise.resolve(emptyResults) };
}
// Streamed so the results list shows a skeleton while it (re-)queries on
@@ -125,8 +126,8 @@ export const load: PageLoad = async ({ url }) => {
const r = await listMyPageTags({ tag, limit: 100 });
return { ...emptyResults, pages: r.items, total: r.page.total ?? 0 };
} catch (e) {
if (e instanceof ApiError) return { ...emptyResults, error: e.message };
throw e;
const message = e instanceof ApiError ? e.message : 'Something went wrong.';
return { ...emptyResults, error: message };
}
})();