mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 04:32:42 +00:00
Largest feature delta in the v1.4.x line. Insights expands into seven dedicated metric sub-pages; GLP-1 medication tracking lands end-to-end (drug-level chart with Research Mode acknowledgment, EMA titration ladder, cadence + compliance, side-effect taxonomy, pen/vial inventory); cross-source priority becomes a two-axis resolver; per-user timezone threads through ten analytics surfaces; Withings activity + sleep v2 sync; onboarding rebuilt as a nested-route wizard; Personal Records ship end-to-end; Health Score provenance accordion; Coach runs native first-party prompts across six locales with a 1800-assertion refusal-probe matrix; OpenAPI drift gate hard-fails; multi-arch GHCR image. Migrations 0043 through 0060 are additive and forward-only. PROMPT_VERSION 4.24.0 → 4.25.0 with GROUND RULE 9 (refuses dose recommendations) and GROUND RULE 15 (refuses drug-level estimates with MDR + MDCG 2021-24 cites). See CHANGELOG.md for the full per-section delta.
28 lines
1.0 KiB
TypeScript
28 lines
1.0 KiB
TypeScript
/**
|
|
* v1.4.25 W21 Fix-N — shared client-side error reader.
|
|
*
|
|
* The four onboarding components (WelcomeCarousel, GoalsChipPicker,
|
|
* SourceCardGrid, BaselineForm) all hand-rolled the same helper to
|
|
* extract the `error` string from a non-OK `apiError` envelope, with an
|
|
* identical fall-through to `Request failed (<status>)`. Hoisting the
|
|
* helper keeps the four call sites honest — the envelope shape only
|
|
* needs to evolve once.
|
|
*
|
|
* Contract:
|
|
* - The server-side `apiError` helper writes `{ data: null, error: "<msg>" }`.
|
|
* - On parse failure (network error, non-JSON body, malformed shape)
|
|
* fall back to a stable string the toast can surface.
|
|
* - Never throw — the caller is already in a catch / setError path.
|
|
*/
|
|
export async function readError(res: Response): Promise<string> {
|
|
try {
|
|
const json = (await res.json()) as { error?: string };
|
|
if (typeof json.error === "string" && json.error.length > 0) {
|
|
return json.error;
|
|
}
|
|
} catch {
|
|
/* fall through */
|
|
}
|
|
return `Request failed (${res.status})`;
|
|
}
|