fix: surface streamed load failures inline
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:
@@ -16,15 +16,14 @@ export const load: PageLoad = async () => {
|
||||
if (e instanceof ApiError && e.status === 401) {
|
||||
return { bookmarks: [], authenticated: false, error: null as string | null };
|
||||
}
|
||||
// Anything else (502 upstream_unavailable from a backend
|
||||
// restart, 500 internal_error) is rendered inline rather than
|
||||
// re-thrown — SvelteKit's generic error.html is not the right
|
||||
// UX for a transient API blip and the user is already
|
||||
// Anything else — an HTTP error (502 upstream_unavailable from
|
||||
// a backend restart, 500 internal_error) or a raw network
|
||||
// failure (a non-ApiError TypeError) — renders inline rather
|
||||
// than re-thrown: SvelteKit's generic error.html is not the
|
||||
// right UX for a transient API blip and the user is already
|
||||
// authenticated as far as we know.
|
||||
if (e instanceof ApiError) {
|
||||
return { bookmarks: [], authenticated: true, error: e.message };
|
||||
}
|
||||
throw e;
|
||||
const message = e instanceof ApiError ? e.message : 'Something went wrong.';
|
||||
return { bookmarks: [], authenticated: true, error: message };
|
||||
}
|
||||
})()
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user