v3: error cards across the app, friendly network errors, code quality pass
This commit is contained in:
@@ -22,6 +22,7 @@ import { PageShell } from "../components/PageShell.tsx";
|
||||
import { PageError } from "../components/PageError.tsx";
|
||||
import { Markdown } from "../components/Markdown.tsx";
|
||||
import { CommentThread } from "../components/CommentThread.tsx";
|
||||
import { friendlyFetchError } from "../utils/apiError.ts";
|
||||
|
||||
type DumpState =
|
||||
| { status: "loading" }
|
||||
@@ -72,9 +73,10 @@ export function Dump() {
|
||||
cache: "no-store",
|
||||
headers: token ? { Authorization: `Bearer ${token}` } : {},
|
||||
});
|
||||
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
||||
|
||||
const apiResponse = await res.json();
|
||||
if (!apiResponse.success) {
|
||||
throw new Error(apiResponse.error?.message ?? "Failed to load dump");
|
||||
}
|
||||
const dump: Dump = deserializeDump(apiResponse.data);
|
||||
setDumpState({ status: "loaded", dump });
|
||||
|
||||
@@ -83,10 +85,7 @@ export function Dump() {
|
||||
.then((r) => r.success && setOp(deserializePublicUser(r.data)))
|
||||
.catch(() => {});
|
||||
} catch (err) {
|
||||
setDumpState({
|
||||
status: "error",
|
||||
error: err instanceof Error ? err.message : "Failed to load dump",
|
||||
});
|
||||
setDumpState({ status: "error", error: friendlyFetchError(err) });
|
||||
}
|
||||
})();
|
||||
}, [selectedDump, preloaded]);
|
||||
|
||||
Reference in New Issue
Block a user